Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

irc-bot #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
import datetime
from dateutil import tz

# use four space indentation only

from_zone = tz.gettz('UTC')
to_zone = tz.gettz('Asia/Kolkata')


def msg_wrapper():
return "PRIVMSG " + channel + " "


def ping(): # responds to server pings
ircsock.send("PONG :pingis\n")

Expand All @@ -19,8 +25,12 @@ def joinchan(chan):
ircsock.send("JOIN " + chan + "\n")


def welcome():
ircsock.send(msg_wrapper() + ":Hello! " + user + " Welcome to jec-dev! Please introduce yourself with name, branch, sem, and area of interest \n ")


def hello():
ircsock.send("PRIVMSG " + channel + " :Hello! Welcome to jec-dev! Happy Hacking! :D\n")
ircsock.send(msg_wrapper() + ":Hello! Welcome to jec-dev! Happy Hacking! :D\n")


if __name__ == '__main__':
Expand All @@ -35,12 +45,15 @@ def hello():
ircsock.setblocking(False)

ircsock.send("USER " + botnick + " " + botnick + " " +
botnick + " Test Bot\n") # user authentication
botnick + " Test Bot\n") # user authentication
# here we actually assign the nick to the bot
ircsock.send("NICK " + botnick + "\n")

joinchan(channel)

with open("user_list_file", 'rb') as usernames:
user_list = usernames.read().split('\n')

while 1:
try:
ircmsg = ircsock.recv(2048)
Expand All @@ -63,6 +76,11 @@ def hello():
user = split_message[0].split('!')[0]
ircmsg = local.time().strftime('%H:%M') + ' ' + user + ' ' + ' '.join(split_message[3:])
log.write(ircmsg+'\n')
if user not in user_list:
welcome()
user_list.append(user)
with open("user_list_file", 'a') as usernames:
usernames.write(user+'\n')
time.sleep(2)
except Exception:
continue
Expand Down
166 changes: 0 additions & 166 deletions logging/index.html

This file was deleted.

23 changes: 0 additions & 23 deletions logging/serve.go

This file was deleted.

16 changes: 0 additions & 16 deletions logging/server.sh

This file was deleted.

89 changes: 0 additions & 89 deletions logging/static/css/style.css

This file was deleted.

Loading