Code aufge-pep8-pt
This commit is contained in:
parent
321e43dc78
commit
bfacdfc284
38
PagerBot.py
38
PagerBot.py
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Author: Bandie Yip Kojote for TTYgap
|
||||
# License: GNU-GPLv3
|
||||
@ -21,7 +21,7 @@ REALNAME="PagerBot"
|
||||
CHAN = "#supercoolchan"
|
||||
|
||||
|
||||
# Mail adress you're sending from
|
||||
# Mail address you're sending from
|
||||
FROM = "ircbot@example.com"
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ phonebook = {}
|
||||
# phonebook["someone"] = "123456"
|
||||
# phonebook["someoneelse"] = "7654321"
|
||||
|
||||
|
||||
def page(receiver, text, user):
|
||||
|
||||
if receiver in phonebook:
|
||||
@ -47,16 +48,14 @@ def page(receiver, text, user):
|
||||
else:
|
||||
return "The username you tried to page has no number saved."
|
||||
|
||||
|
||||
|
||||
|
||||
to = number + "@ecityruf.de"
|
||||
message = HOST + ":" + user + ":" + text
|
||||
if(len(message) > 80):
|
||||
return "The message \"%s\" is too big. It has to be less than 80 characters.\r\n" % (message)
|
||||
m = smtplib.SMTP('smtpgw3.emessage.de')
|
||||
try:
|
||||
m.sendmail(FROM, to, "FROM: %s\nTO: %s\nSUBJECT: %s" % (FROM, to, message))
|
||||
m.sendmail(FROM, to, "FROM: %s\nTO: %s\nSUBJECT: %s" %
|
||||
(FROM, to, message))
|
||||
except:
|
||||
e = sys.exc_info()[0]
|
||||
return "Error: %s" % e
|
||||
@ -64,11 +63,6 @@ def page(receiver, text, user):
|
||||
return "Sent."
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
readbuffer = ""
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
@ -92,8 +86,6 @@ while 1:
|
||||
line = string.rstrip(line)
|
||||
line = string.split(line)
|
||||
|
||||
|
||||
|
||||
if(line[0] == "PING"):
|
||||
ircsock.send("PONG %s\r\n" % line[1])
|
||||
|
||||
@ -104,20 +96,24 @@ while 1:
|
||||
|
||||
if("#" in line[2]):
|
||||
if(line[3] == ":%s:" % (NICK) or line[3] == ":&pager"):
|
||||
ircsock.send("PRIVMSG %s %s: I only do stuff via query.\r\n" % (line[2], usernick))
|
||||
ircsock.send(
|
||||
"PRIVMSG %s %s: I only do stuff via query.\r\n" % (line[2], usernick))
|
||||
|
||||
if("#" not in line[2]):
|
||||
if(line[3] == ":help"):
|
||||
ircsock.send("PRIVMSG %s This is a bot to use a paging service.\r\n" % (usernick))
|
||||
ircsock.send(
|
||||
"PRIVMSG %s This is a bot to use a paging service.\r\n" % (usernick))
|
||||
time.sleep(1)
|
||||
ircsock.send("PRIVMSG %s Use \"/msg %s &pager <Username> <Message>\" to page someone.\r\n" % (usernick, NICK))
|
||||
ircsock.send(
|
||||
"PRIVMSG %s Use \"/msg %s &pager <Username> <Message>\" to page someone.\r\n" % (usernick, NICK))
|
||||
elif(line[3] == ":&pager"):
|
||||
pagingtext = ' '.join(line[5:])
|
||||
print("%s tries to send to %s \"%s\"\n" % (usernick, line[4], pagingtext))
|
||||
ircsock.send("PRIVMSG %s %s\r\n" % (usernick, page(line[4], pagingtext, usernick)))
|
||||
print("%s tries to send to %s \"%s\"\n" %
|
||||
(usernick, line[4], pagingtext))
|
||||
ircsock.send("PRIVMSG %s %s\r\n" %
|
||||
(usernick, page(line[4], pagingtext, usernick)))
|
||||
elif(line[3] == ":&phonebook"):
|
||||
ircsock.send("PRIVMSG %s %s\r\n" % (usernick, phonebook.keys()))
|
||||
ircsock.send("PRIVMSG %s %s\r\n" %
|
||||
(usernick, phonebook.keys()))
|
||||
|
||||
# print(line)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user