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
|
# Author: Bandie Yip Kojote for TTYgap
|
||||||
# License: GNU-GPLv3
|
# License: GNU-GPLv3
|
||||||
@ -21,7 +21,7 @@ REALNAME="PagerBot"
|
|||||||
CHAN = "#supercoolchan"
|
CHAN = "#supercoolchan"
|
||||||
|
|
||||||
|
|
||||||
# Mail adress you're sending from
|
# Mail address you're sending from
|
||||||
FROM = "ircbot@example.com"
|
FROM = "ircbot@example.com"
|
||||||
|
|
||||||
|
|
||||||
@ -40,6 +40,7 @@ phonebook = {}
|
|||||||
# phonebook["someone"] = "123456"
|
# phonebook["someone"] = "123456"
|
||||||
# phonebook["someoneelse"] = "7654321"
|
# phonebook["someoneelse"] = "7654321"
|
||||||
|
|
||||||
|
|
||||||
def page(receiver, text, user):
|
def page(receiver, text, user):
|
||||||
|
|
||||||
if receiver in phonebook:
|
if receiver in phonebook:
|
||||||
@ -47,16 +48,14 @@ def page(receiver, text, user):
|
|||||||
else:
|
else:
|
||||||
return "The username you tried to page has no number saved."
|
return "The username you tried to page has no number saved."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
to = number + "@ecityruf.de"
|
to = number + "@ecityruf.de"
|
||||||
message = HOST + ":" + user + ":" + text
|
message = HOST + ":" + user + ":" + text
|
||||||
if(len(message) > 80):
|
if(len(message) > 80):
|
||||||
return "The message \"%s\" is too big. It has to be less than 80 characters.\r\n" % (message)
|
return "The message \"%s\" is too big. It has to be less than 80 characters.\r\n" % (message)
|
||||||
m = smtplib.SMTP('smtpgw3.emessage.de')
|
m = smtplib.SMTP('smtpgw3.emessage.de')
|
||||||
try:
|
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:
|
except:
|
||||||
e = sys.exc_info()[0]
|
e = sys.exc_info()[0]
|
||||||
return "Error: %s" % e
|
return "Error: %s" % e
|
||||||
@ -64,11 +63,6 @@ def page(receiver, text, user):
|
|||||||
return "Sent."
|
return "Sent."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
readbuffer = ""
|
readbuffer = ""
|
||||||
|
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
@ -92,8 +86,6 @@ while 1:
|
|||||||
line = string.rstrip(line)
|
line = string.rstrip(line)
|
||||||
line = string.split(line)
|
line = string.split(line)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(line[0] == "PING"):
|
if(line[0] == "PING"):
|
||||||
ircsock.send("PONG %s\r\n" % line[1])
|
ircsock.send("PONG %s\r\n" % line[1])
|
||||||
|
|
||||||
@ -104,20 +96,24 @@ while 1:
|
|||||||
|
|
||||||
if("#" in line[2]):
|
if("#" in line[2]):
|
||||||
if(line[3] == ":%s:" % (NICK) or line[3] == ":&pager"):
|
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("#" not in line[2]):
|
||||||
if(line[3] == ":help"):
|
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)
|
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"):
|
elif(line[3] == ":&pager"):
|
||||||
pagingtext = ' '.join(line[5:])
|
pagingtext = ' '.join(line[5:])
|
||||||
print("%s tries to send to %s \"%s\"\n" % (usernick, line[4], pagingtext))
|
print("%s tries to send to %s \"%s\"\n" %
|
||||||
ircsock.send("PRIVMSG %s %s\r\n" % (usernick, page(line[4], pagingtext, usernick)))
|
(usernick, line[4], pagingtext))
|
||||||
|
ircsock.send("PRIVMSG %s %s\r\n" %
|
||||||
|
(usernick, page(line[4], pagingtext, usernick)))
|
||||||
elif(line[3] == ":&phonebook"):
|
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)
|
# print(line)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user