Merge pull request #5 from benharri/master

fix ping, systemd example
This commit is contained in:
RussellChamp authored and GitHub committed 2018-10-05 14:01:01 -04:00
commit e5c499d86e
8 files changed
+63 -48

No files matched your search

+6 -6
View File
@@ -43,8 +43,8 @@ parser.add_option("-n", "--nick", dest="nick", default='tildebot',
p = inflect.engine()
def ping():
ircsock.send("PONG :pingis\n")
def ping(pong):
ircsock.send("PONG {}\n".format(pong))
def sendmsg(chan , msg):
ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
@@ -263,8 +263,8 @@ def listen(botnick):
ircmsg = ircsock.recv(2048)
ircmsg = ircmsg.strip('\n\r')
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
formatted = formatter.format_message(ircmsg)
@@ -337,8 +337,8 @@ def listen(botnick):
if ircmsg.find(":" + botnick + ":") != -1:
mug_off(channel)
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
sys.stdout.flush()
time.sleep(1)
+5 -5
View File
@@ -25,7 +25,7 @@ class State:
MAX_LINE = 80 # The maximum number of characters in a line
MAX_STORIES = 5 # The maximum number of stories a user can pick from
THROTTLE_FACTOR = 1 # A factor by which all sleep event durations will be multiplied
# Allow madlbibbot to run multiple simultaneous stories
# Allow madlbibbot to run multiple simultaneous stories
state = {} # The current state of the bot
stories = {} # The list of stories available to users
story = {} # The madlib story currently being worked on
@@ -179,8 +179,8 @@ def finish_story(channel):
state[channel] = State.idle
# System things
def ping():
ircsock.send("PONG :pingis\n")
def ping(pong):
ircsock.send("PONG {}\n".format(pong))
def sendmsg(chan , msg):
ircsock.send("PRIVMSG {} :{}\n".format(chan, msg))
@@ -212,8 +212,8 @@ def listen(botnick):
ircmsg = ircsock.recv(2048)
ircmsg = ircmsg.strip('\n\r')
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
formatted = msgformatter.format_message(ircmsg)
if "" == formatted:
+10 -10
View File
@@ -22,11 +22,11 @@ parser.add_option("-n", "--nick", dest="nick", default='quote_bot',
(options, args) = parser.parse_args()
def ping():
ircsock.send("PONG :pingis\n")
def ping(pong):
ircsock.send("PONG {}\n".format(pong))
def sendmsg(chan , msg):
ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
def joinchan(chan):
ircsock.send("JOIN "+ chan +"\n")
@@ -74,21 +74,21 @@ def say_chatty(channel):
for line in chattyOut:
if line:
ircsock.send("PRIVMSG "+ channel + " :" + line + "\n")
def listen():
while 1:
ircmsg = ircsock.recv(2048)
ircmsg = ircmsg.strip('\n\r')
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
formatted = formatter.format_message(ircmsg)
if "" == formatted:
continue
print formatted
split = formatted.split("\t")
@@ -108,8 +108,8 @@ def listen():
if ircmsg.find(":!haiku") != -1:
haiku(options.channel)
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
sys.stdout.flush()
time.sleep(1)
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=tildebot daemon
After=tildebot.service
[Service]
Type=simple
ExecStart=/home/krowbar/Code/irc/tildebot.py -s 127.0.0.1 -n tildebot -c \#tildetown
WorkingDirectory=/home/krowbar/Code/irc/
Restart=always
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=default.target
+9 -9
View File
@@ -22,11 +22,11 @@ parser.add_option("-n", "--nick", dest="nick", default='tilde_bot',
(options, args) = parser.parse_args()
def ping():
ircsock.send("PONG :pingis\n")
def ping(pong):
ircsock.send("PONG {}\n".format(pong))
def sendmsg(chan , msg):
ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
def joinchan(chan):
ircsock.send("JOIN "+ chan +"\n")
@@ -61,14 +61,14 @@ def listen():
ircmsg = ircsock.recv(2048)
ircmsg = ircmsg.strip('\n\r')
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
formatted = formatter.format_message(ircmsg)
if "" == formatted:
continue
print formatted
split = formatted.split("\t")
@@ -79,8 +79,8 @@ def listen():
if ircmsg.find(":!tilde") != -1:
tilde(options.channel, user, time)
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
sys.stdout.flush()
+6 -6
View File
@@ -36,8 +36,8 @@ JACKPOT_FILE = "tildejackpot.txt"
JACKPOT_MIN = 3
DEBUG = False
def ping():
ircsock.send("PONG :pingis\n")
def ping(pong):
ircsock.send("PONG {}\n".format(pong))
def sendmsg(chan , msg):
ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
@@ -181,8 +181,8 @@ def listen():
for msg in ircmsg.split('\n'):
msg = msg.strip('\n\r')
if msg.find("PING :") != -1:
ping()
if msg[:4] == "PING":
ping(msg.split(" ")[1])
formatted = formatter.format_message(msg)
@@ -213,8 +213,8 @@ def listen():
if msg.find(":!rollcall") != -1:
rollcall(channel)
if msg.find("PING :") != -1:
ping()
if msg[:4] == "PING":
ping(msg.split(" ")[1])
sys.stdout.flush()
time.sleep(1)
+6 -6
View File
@@ -30,8 +30,8 @@ parser.add_option("-n", "--nick", dest="nick", default='topicbot',
p = inflect.engine()
def ping():
ircsock.send("PONG :pingis\n")
def ping(pong):
ircsock.send("PONG {}\n".format(pong))
def sendmsg(chan , msg):
ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
@@ -145,8 +145,8 @@ def listen():
ircmsg = ircsock.recv(2048)
ircmsg = ircmsg.strip('\n\r')
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
formatted = formatter.format_message(ircmsg)
@@ -187,8 +187,8 @@ def listen():
if ircmsg.find(":!rollcall") != -1:
rollcall(channel)
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
sys.stdout.flush()
time.sleep(1)
+6 -6
View File
@@ -56,8 +56,8 @@ def resetGlobals():
currentScores.clear()
def ping():
ircsock.send("PONG :pingis\n")
def ping(pong):
ircsock.send("PONG {}\n".format(pong))
def sendmsg(chan , msg):
ircsock.send("PRIVMSG "+ chan +" :"+ msg +"\n")
@@ -220,8 +220,8 @@ def listen():
ircmsg = ircsock.recv(2048)
ircmsg = ircmsg.strip('\n\r')
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
formatted = formatter.format_message(ircmsg)
@@ -254,8 +254,8 @@ def listen():
if ircmsg.find(":!rollcall") != -1:
rollcall(channel)
if ircmsg.find("PING :") != -1:
ping()
if ircmsg[:4] == "PING":
ping(ircmsg.split(" ")[1])
sys.stdout.flush()
time.sleep(1)