1
0
Fork 0

a few cleanups

This commit is contained in:
fanir 2014-03-01 01:34:46 +01:00
parent 69e20b40f5
commit 91c86c1d92

17
main.py
View file

@ -26,13 +26,12 @@
# SETTINGS CAN BE FOUND AT THE BOTTOM OF THE FILE # SETTINGS CAN BE FOUND AT THE BOTTOM OF THE FILE
import sys, time, string, socket, re, signal, struct import sys, string, socket, re, signal
from time import sleep
from select import poll, POLLIN, POLLPRI, POLLOUT,\ from select import poll, POLLIN, POLLPRI, POLLOUT,\
POLLERR, POLLHUP, POLLNVAL POLLERR, POLLHUP, POLLNVAL
from threading import Thread, Event from threading import Thread, Event
from APIcollection import Twitter
bot = None bot = None
@ -158,7 +157,7 @@ class pircbot():
log.show(log.WARNING, "Got killed by %s: %s" % (params[0], params[1:])) log.show(log.WARNING, "Got killed by %s: %s" % (params[0], params[1:]))
self.quit(send=False) self.quit(send=False)
else: else:
time.sleep(self.parser_wait_time) sleep(self.parser_wait_time)
print("--- PARSELOOP EXITING ---") print("--- PARSELOOP EXITING ---")
def send(self, data): def send(self, data):
@ -207,15 +206,15 @@ class pircbot():
except: pass except: pass
def join(self, channel): def join(self, channel):
while not self.ready: time.sleep(1) while not self.ready: sleep(1)
self.send("JOIN %s" % channel) self.send("JOIN %s" % channel)
def part(self, channel): def part(self, channel):
while not self.ready: time.sleep(1) while not self.ready: sleep(1)
self.send("PART %s" % channel) self.send("PART %s" % channel)
def set_mode(self, modes): def set_mode(self, modes):
while not self.ready: time.sleep(1) while not self.ready: sleep(1)
self.send("MODE %s :%s" % (self.user["nick"], modes)) self.send("MODE %s :%s" % (self.user["nick"], modes))
def on_command(self, prefix, origin, source, command, params): def on_command(self, prefix, origin, source, command, params):
@ -270,7 +269,7 @@ def main():
bot.connect() bot.connect()
# wait for the bot to become ready # wait for the bot to become ready
while bot.ready and not bot.die_event.is_set() == False: while bot.ready and not bot.die_event.is_set() == False:
time.sleep(1) sleep(1)
if not bot.die_event.is_set(): if not bot.die_event.is_set():
# set modes and join channels # set modes and join channels
@ -280,7 +279,7 @@ def main():
# while bot is active, do nothing # while bot is active, do nothing
while not bot.die_event.is_set(): while not bot.die_event.is_set():
time.sleep(1) sleep(1)
except KeyboardInterrupt: except KeyboardInterrupt:
log.show(log.INFO, "Got Ctrl-C, dying now...") log.show(log.INFO, "Got Ctrl-C, dying now...")
bot.quit() bot.quit()