I am not a smart person sometimes
This commit is contained in:
parent
fd7253ded7
commit
6518fe7136
|
@ -18,7 +18,6 @@ print 'CloudBot DEV <http://git.io/cloudbotirc>'
|
||||||
# create new bot object
|
# create new bot object
|
||||||
bot = Bot()
|
bot = Bot()
|
||||||
bot.vars = {}
|
bot.vars = {}
|
||||||
bot.history = {}
|
|
||||||
|
|
||||||
# record start time for the uptime command
|
# record start time for the uptime command
|
||||||
bot.start_time = time.time()
|
bot.start_time = time.time()
|
||||||
|
|
|
@ -135,6 +135,7 @@ class IRC(object):
|
||||||
self.server = server
|
self.server = server
|
||||||
self.port = port
|
self.port = port
|
||||||
self.nick = nick
|
self.nick = nick
|
||||||
|
self.history = {}
|
||||||
self.vars = {}
|
self.vars = {}
|
||||||
|
|
||||||
self.out = Queue.Queue() # responses from the server are placed here
|
self.out = Queue.Queue() # responses from the server are placed here
|
||||||
|
|
|
@ -6,7 +6,7 @@ CORRECTION_RE = r'^(s|S)/.*/.*/?\S*$'
|
||||||
|
|
||||||
|
|
||||||
@hook.regex(CORRECTION_RE)
|
@hook.regex(CORRECTION_RE)
|
||||||
def correction(match, input=None, bot=None, message=None):
|
def correction(match, input=None, conn=None, message=None):
|
||||||
split = input.msg.split("/")
|
split = input.msg.split("/")
|
||||||
|
|
||||||
if len(split) == 4:
|
if len(split) == 4:
|
||||||
|
@ -17,7 +17,7 @@ def correction(match, input=None, bot=None, message=None):
|
||||||
find = split[1]
|
find = split[1]
|
||||||
replace = split[2]
|
replace = split[2]
|
||||||
|
|
||||||
for item in bot.history[input.chan].__reversed__():
|
for item in conn.history[input.chan].__reversed__():
|
||||||
name, timestamp, msg = item
|
name, timestamp, msg = item
|
||||||
if msg.startswith("s/"):
|
if msg.startswith("s/"):
|
||||||
# don't correct corrections, it gets really confusing
|
# don't correct corrections, it gets really confusing
|
||||||
|
|
|
@ -28,12 +28,12 @@ def track_seen(input, message_time, db):
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
def track_history(input, message_time, bot):
|
def track_history(input, message_time, conn):
|
||||||
try:
|
try:
|
||||||
history = bot.history[input.chan]
|
history = conn.history[input.chan]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
bot.history[input.chan] = deque(maxlen=100)
|
conn.history[input.chan] = deque(maxlen=100)
|
||||||
history = bot.history[input.chan]
|
history = conn.history[input.chan]
|
||||||
|
|
||||||
data = (input.nick, message_time, input.msg)
|
data = (input.nick, message_time, input.msg)
|
||||||
history.append(data)
|
history.append(data)
|
||||||
|
@ -41,17 +41,17 @@ def track_history(input, message_time, bot):
|
||||||
|
|
||||||
@hook.singlethread
|
@hook.singlethread
|
||||||
@hook.event('PRIVMSG', ignorebots=False)
|
@hook.event('PRIVMSG', ignorebots=False)
|
||||||
def chat_tracker(paraml, input=None, db=None, bot=None):
|
def chat_tracker(paraml, input=None, db=None, conn=None):
|
||||||
message_time = time.time()
|
message_time = time.time()
|
||||||
track_seen(input, message_time, db)
|
track_seen(input, message_time, db)
|
||||||
track_history(input, message_time, bot)
|
track_history(input, message_time, conn)
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False)
|
@hook.command(autohelp=False)
|
||||||
def resethistory(inp, input=None, bot=None):
|
def resethistory(inp, input=None, conn=None):
|
||||||
"""resethistory - Resets chat history for the current channel"""
|
"""resethistory - Resets chat history for the current channel"""
|
||||||
try:
|
try:
|
||||||
bot.history[input.chan].clear()
|
conn.history[input.chan].clear()
|
||||||
return "Reset chat history for current channel."
|
return "Reset chat history for current channel."
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# wat
|
# wat
|
||||||
|
|
|
@ -87,7 +87,7 @@ def mcuser(inp):
|
||||||
profile["lt"] = ", legacy" if profile["legacy"] else ""
|
profile["lt"] = ", legacy" if profile["legacy"] else ""
|
||||||
|
|
||||||
if profile["paid"]:
|
if profile["paid"]:
|
||||||
return u"The account \x02{name}\x02 ({id}{lt}) exists. It is a \x033\x02paid\x02\x0f" \
|
return u"The account \x02{name}\x02 ({id}{lt}) exists. It is a \x02paid\x02" \
|
||||||
u" account.".format(**profile)
|
u" account.".format(**profile)
|
||||||
else:
|
else:
|
||||||
return u"The account \x02{name}\x02 ({id}{lt}) exists. It \x034\x02is NOT\x02\x0f a paid" \
|
return u"The account \x02{name}\x02 ({id}{lt}) exists. It \x034\x02is NOT\x02\x0f a paid" \
|
||||||
|
|
Reference in New Issue