Compare commits
No commits in common. "4140f52c696278cf2e8354f2b98abc7df8c114a8" and "feb33e2345a8cd20926c6d9fc2e6ffef04a33e51" have entirely different histories.
4140f52c69
...
feb33e2345
|
@ -15,7 +15,7 @@ def help(bot, trigger):
|
||||||
name = trigger.group(2)
|
name = trigger.group(2)
|
||||||
name = name.lower()
|
name = name.lower()
|
||||||
if name not in bot.commands:
|
if name not in bot.commands:
|
||||||
return bot.msg("Command not found.")
|
return
|
||||||
cmd = bot.commands[name]
|
cmd = bot.commands[name]
|
||||||
docstring, examples = cmd.doc
|
docstring, examples = cmd.doc
|
||||||
if examples:
|
if examples:
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
"""
|
"""
|
||||||
When was this user last seen.
|
When was this user last seen.
|
||||||
"""
|
"""
|
||||||
import os
|
|
||||||
import time
|
import time
|
||||||
import argparse
|
import argparse
|
||||||
import threading
|
import threading
|
||||||
|
@ -12,7 +11,7 @@ from sqlite3 import OperationalError
|
||||||
from requests.structures import CaseInsensitiveDict
|
from requests.structures import CaseInsensitiveDict
|
||||||
|
|
||||||
from tools.time import relativeTime
|
from tools.time import relativeTime
|
||||||
from module import commands, example, hook, require_chanmsg, rate
|
from module import commands, example, hook, require_chanmsg
|
||||||
|
|
||||||
|
|
||||||
def load_database(bot):
|
def load_database(bot):
|
||||||
|
@ -50,7 +49,7 @@ def setup(bot):
|
||||||
bot.memory["seen"] = load_database(bot)
|
bot.memory["seen"] = load_database(bot)
|
||||||
bot.memory["seen_last_dump"] = time.time()
|
bot.memory["seen_last_dump"] = time.time()
|
||||||
|
|
||||||
@rate(1)
|
|
||||||
@commands('seen')
|
@commands('seen')
|
||||||
@example(".seen Nigger -l", "Last heard from Nigger at [1997-03-12 16:30:00] "\
|
@example(".seen Nigger -l", "Last heard from Nigger at [1997-03-12 16:30:00] "\
|
||||||
+"with \"Just going to the store for some smokes babe I'll be right back\"")
|
+"with \"Just going to the store for some smokes babe I'll be right back\"")
|
||||||
|
@ -61,7 +60,6 @@ def seen(bot, trigger):
|
||||||
--last [-l] reports when the user was last seen. This is the default.
|
--last [-l] reports when the user was last seen. This is the default.
|
||||||
--first [-f] reports when the user was first seen.
|
--first [-f] reports when the user was first seen.
|
||||||
--message [-m] includes the first/last message the user sent.
|
--message [-m] includes the first/last message the user sent.
|
||||||
--context [-c] includes irc logs before and after their last message as context. Implies --message.
|
|
||||||
"""
|
"""
|
||||||
if not trigger.group(2):
|
if not trigger.group(2):
|
||||||
return bot.reply("Seen who?")
|
return bot.reply("Seen who?")
|
||||||
|
@ -71,7 +69,6 @@ def seen(bot, trigger):
|
||||||
parser.add_argument("-l", "--last", action="store_true", default=True)
|
parser.add_argument("-l", "--last", action="store_true", default=True)
|
||||||
parser.add_argument("-f", "--first", action="store_true")
|
parser.add_argument("-f", "--first", action="store_true")
|
||||||
parser.add_argument("-m", "--message", action="store_true")
|
parser.add_argument("-m", "--message", action="store_true")
|
||||||
parser.add_argument("-c", "--context", action="store_true")
|
|
||||||
args = parser.parse_args(trigger.group[3:])
|
args = parser.parse_args(trigger.group[3:])
|
||||||
|
|
||||||
if args.nick == bot.nick:
|
if args.nick == bot.nick:
|
||||||
|
@ -103,24 +100,6 @@ def seen(bot, trigger):
|
||||||
|
|
||||||
bot.msg(msg)
|
bot.msg(msg)
|
||||||
|
|
||||||
if args.context:
|
|
||||||
num_con_lines = 2
|
|
||||||
fname = os.path.join(bot.log_path, bot.hostname,channel,timestamp[1:11])
|
|
||||||
fname += ".log"
|
|
||||||
if not os.path.isfile(fname):
|
|
||||||
return bot.msg("Context not available.")
|
|
||||||
with open(fname, "r") as file:
|
|
||||||
data = file.read().splitlines()
|
|
||||||
matches = [line for line in data if line.startswith(timestamp)]
|
|
||||||
if not matches:
|
|
||||||
return bot.msg("Context not available")
|
|
||||||
index = data.index(matches[0]) # a bit lazy, but w/e
|
|
||||||
start = max([index - num_con_lines, 0])
|
|
||||||
end = min([index + num_con_lines+1, len(data) - 1])
|
|
||||||
bot.msg("Context:")
|
|
||||||
bot.msg("\n".join(data[start:end]))
|
|
||||||
del data
|
|
||||||
|
|
||||||
|
|
||||||
def dump_seen_db(bot):
|
def dump_seen_db(bot):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user