Compare commits
19 Commits
Author | SHA1 | Date |
---|---|---|
Christine Dodrill | 4cb24196ef | |
Christine Dodrill | 2276e66732 | |
Christine Dodrill | c1a276366e | |
Christine Dodrill | 81bf7da25a | |
Christine Dodrill | efc5d32de7 | |
Christine Dodrill | 441a5707b9 | |
Christine Dodrill | 82f6dc4e07 | |
Christine Dodrill | a5a9e25643 | |
Christine Dodrill | f33fad269c | |
Christine Dodrill | 9c59c4e3f8 | |
Christine Dodrill | c8b152e3fe | |
Christine Dodrill | 4d5a05614d | |
Christine Dodrill | c73752c3eb | |
Christine Dodrill | 97e69503a6 | |
Christine Dodrill | 7a7e8e21f2 | |
Christine Dodrill | 71e1675d57 | |
Christine Dodrill | ec4d9c9f20 | |
Christine Dodrill | d3b1b154ee | |
Christine Dodrill | 941047900a |
27
LICENSE
27
LICENSE
|
@ -1,24 +1,7 @@
|
|||
This is free and unencumbered software released into the public domain.
|
||||
Copyright 2015 Christine Dodrill <xena@yolo-swag.com>
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
Usage of the works is permitted provided that this instrument is retained
|
||||
with the works, so that any entity that uses the works is notified of
|
||||
this instrument.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
|
|
@ -61,7 +61,7 @@ class Input(dict):
|
|||
self[key] = value
|
||||
|
||||
|
||||
@fuckit
|
||||
#@fuckit
|
||||
def run(func, input):
|
||||
args = func._args
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import re
|
||||
import requests
|
||||
from util import hook
|
||||
|
||||
@hook.command
|
||||
@hook.regex("^feel good fact$", re.IGNORECASE)
|
||||
def compliment(inp):
|
||||
r = requests.get("http://compliment.b303.me/")
|
||||
return r.text
|
|
@ -0,0 +1,32 @@
|
|||
This guy Lucas has got us all by the balls. His fingers are in our wallets. Get your finger out of my ass wallet!
|
||||
The Millennium Falcon is safe. It was not raped. Where would you rape the Millennium Falcon anyway?
|
||||
I'm gonna fuck my cat and eat my cat and I'm gonna kidnap a hooker, and it'll help me fuck the pain away.
|
||||
Now I've analyzed this movie with a team of cheerleaders, who all came to one unanymous conclusion: that if I let them go, they won't tell nobody.
|
||||
What red-blooded male wouldn't want to dock his canoe in Natalie's port, man?
|
||||
Empire pulled this off perfectly, of course. 'Cause I love Empire so much I fuck it.
|
||||
Oh, my pizza rolls is done. You want some pizza rolls? Are ya sure? They're really good pizza rolls. They're hot and pizza-y.
|
||||
This is what they call filler, and it's nowhere near as good as the kind they put in Twinkies. Mmmmm...I like to fuck my cat.
|
||||
Paging Dr. Plinkett. Dr. Plinkett is in, I'm here. Somebody pass the Vicodin. No, wait, we need Ambien. Well, we sure need some-thien.
|
||||
And someone even said it was the bestest movie ever because it had lava in it. Aw, ain't he cute? His name is Johnny. I adopted him, from a grocery store parking lot.
|
||||
Even Ray Charles could see that coming, and he doesn't know anything about Star Wars.
|
||||
There are two types of people in this world: people that understand what I'm saying, and people that like the Star Wars prequels.
|
||||
Now, is General Grievous supposed to be funny? Cause they said he was a villain, not a comedian, like Larry Seinfeld. But rather a creepy weirdo, like Jerry Flint. I'm so confused.
|
||||
Baby's Day Out is about as interesting as my taint.
|
||||
When will I get my merkins in the mail?
|
||||
Anybody wanna help me milk my cock? http://i.imgur.com/vvfu4Y5.jpg
|
||||
You see, a guy named William Shakesman once said, "Brevity is the soul of wit." This just means "Don't waste my time." You keep it nice and simple.
|
||||
Anybody want a pizza roll? Post a comment on this webzone if you want a pizza roll.
|
||||
Who's fucking with my medicine?
|
||||
It's good to show contempt for your audience. Just ask Michael Bay.
|
||||
The entire senate is filled with stupid idiots.
|
||||
Aw, ain't he cute? His name is Johnny. I adopted him from a grocery store parking lot.
|
||||
Trust me, I'm a doctor. Kind of.
|
||||
Stop feeding us this pig slop! I'm only half pig.
|
||||
What red-blooded male wouldn't want to dock his canoe in Natalie's port, man?
|
||||
Anybody wanna help me milk my cat? It's time to make breakfast.
|
||||
Palpatine's behind it all.
|
||||
See, when you say something right to a woman, she smiles, it tickles her brain, which in turns sends blood flowing down to her sex hole.
|
||||
My cat ain't gonna milk itself!
|
||||
Sometimes a cigar is just a giant vagina in the desert that swallows men whole.
|
||||
What's wrong with your face?
|
||||
Get outta my house. Get outta my creepy house. Don't go in my basement either.
|
|
@ -0,0 +1,315 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import sys, os
|
||||
import random
|
||||
import string
|
||||
import re
|
||||
|
||||
choice = random.choice
|
||||
randint = random.randint
|
||||
|
||||
def dc(n, m=20):
|
||||
return n < randint(0, m-1)
|
||||
|
||||
base_noun = [
|
||||
'TCP', 'IP', 'UDP', 'BGP', 'DNS', 'ARP spoof', 'ARP', 'JavaScript',
|
||||
'HTML', 'CSS', 'XML', 'SOAP', 'REST', 'SSL', 'socket', 'BSD', 'linux',
|
||||
'MPI', 'OpenMP', 'SYN/ACK', 'kernel', 'ELF', 'COFF', '68000', 'x86',
|
||||
'MIPS', 'ethernet', 'MAC', 'C', 'C++', 'Java', 'JSON', 'ruby',
|
||||
'python', 'linked list', 'radix trie', 'hash table', 'SQL', 'makefile',
|
||||
'/proc', '/dev/null', 'tty', 'regex', 'sed', 'vim', 's/// operation',
|
||||
'operation', 'port scanner', 'port scan', 'lookup table', 'anti-<noun>',
|
||||
'<verber> manual', '<verber> config', 'IRC', 'IRC bot', 'bootloader',
|
||||
'GNU/<noun>',
|
||||
]
|
||||
|
||||
|
||||
# I suppose it would be easier to create rules for a lot of these, but
|
||||
# I think LUTs are fine.
|
||||
|
||||
base_verb = [
|
||||
( 'compile', '-s', '-d', '-r', 'compiling' ),
|
||||
( 'link', '-s', '-ed', '-er', '-ing' ),
|
||||
( 'assemble', '-s', '-d', '-r', 'assembling' ),
|
||||
( 'load', '-s', '-ed', '-er', '-ing' ),
|
||||
( 'boot', '-s', '-ed', '-er', '-ing' ),
|
||||
( 'reset', '-s', 'reset', '-ter', '-ting' ),
|
||||
( 'remove', '-s', '-d', '-r', 'removing' ),
|
||||
( 'decompile', '-s', '-d', '-r', 'decompiling' ),
|
||||
( 'unlink', '-s', '-ed', '-er', '-ing' ),
|
||||
( 'disassemble', '-s', '-d', '-r', 'disassembling' ),
|
||||
( 'unload', '-s', '-ed', '-er', '-ing' ),
|
||||
( 'parse', '-s', '-d', '-r', 'parsing' ),
|
||||
( 'archive', '-s', '-d', '-r', 'archiving' ),
|
||||
( 'cherry-pick', '-s', '-ed', '-er', '-ing' ),
|
||||
( 'overwrite', '-s', 'overwrote', '-r', 'overwriting' ),
|
||||
( 'edit', '-s', '-ed', '-or', '-ing' ),
|
||||
( 'compute', '-s', '-d', '-r', 'computing' ),
|
||||
( 'release', '-s', '-d', '-r', 'releasing' ),
|
||||
( 'transmit', '-s', '-ted', '-ter', '-ting' ),
|
||||
( 'receive', '-s', '-d', '-r', 'receiving' ),
|
||||
( 'analyze', '-s', '-d', '-r', 'analyzing' ),
|
||||
( 'print', '-s', '-ed', '-er', '-ing' ),
|
||||
( 'save', '-s', '-d', '-r', 'saving' ),
|
||||
( 'erase', '-s', '-d', '-r', 'erasing' ),
|
||||
( 'install', '-s', '-ed', '-er', '-ing' ),
|
||||
( 'scan', '-s', '-ned', '-ner', '-ning' ),
|
||||
( 'port scan', '-s', '-ned', '-ner', '-ning' ),
|
||||
( 'nmap', '-s', '-ped', '-per', '-ping' ),
|
||||
( 'DDOS', '-es', '-sed', '-ser', '-sing' ),
|
||||
( 'exploit', '-s', '-ed', '-er', '-ing' ),
|
||||
( 'send', '-s', 'sent', '-er', '-ing' ),
|
||||
( 'write', '-s', 'wrote', '-r', 'writing' ),
|
||||
( 'detect', '-s', '-ed', '-or', '-ing' ),
|
||||
( 'sniff', '-s', '-ed', '-er', '-ing' ),
|
||||
|
||||
( 'look up', 'looks up', 'looked up', 'looker upper', 'looking up' ),
|
||||
( 'check out', 'checks out', 'checked out', 'checker outer', 'checking out' ),
|
||||
( 'query', 'queries', 'queried', 'querier', 'querying' ),
|
||||
]
|
||||
|
||||
base_service = [
|
||||
'Google', 'Amazon', 'Stack Overflow', 'Freenode', 'EFnet', 'Usenet',
|
||||
'this old GeoCities page', 'my website', '<person>\'s website',
|
||||
]
|
||||
|
||||
base_hack_object = [
|
||||
'the <noun>', 'a(n) <noun>', 'the victim\'s <noun>', 'some <noun>',
|
||||
'a(n) <verber> from <service>', '<service>\'s <noun>',
|
||||
'the freeware <noun>', 'a configurable <noun>', 'a working <noun>',
|
||||
'a pre-<verbed> <verber>',
|
||||
]
|
||||
|
||||
base_tool = [
|
||||
'<noun> <verber>',
|
||||
'<verbed> <noun>',
|
||||
'<verber>',
|
||||
'<verber> for <nouns>',
|
||||
'<verbing> <tool>',
|
||||
'thing that <verbs>',
|
||||
'thing for <verbing> <nouns>',
|
||||
'pre-<noun> <verber>',
|
||||
'anti-<noun> <verber>',
|
||||
'<verbing> tool',
|
||||
'<verber> subsystem',
|
||||
'professional <verber>',
|
||||
'<verber>-<verber> hybrid',
|
||||
]
|
||||
|
||||
base_tools = [
|
||||
'<noun> <verber>s',
|
||||
'<verbed> <nouns>',
|
||||
'<verber>s',
|
||||
'<verbing> <tools>',
|
||||
'things for <verbing>',
|
||||
'pre-<noun> <verber>s',
|
||||
]
|
||||
|
||||
base_person = [
|
||||
'Linus Torvalds',
|
||||
'Alan Cox',
|
||||
'Con Colivas',
|
||||
'Ingo Molnar',
|
||||
'Hans Reiser',
|
||||
'Ulrich Drepper',
|
||||
'Larry Wall',
|
||||
'William Pitcock',
|
||||
'Bill Gates',
|
||||
'Ken Thompson',
|
||||
'Brian Khernigan',
|
||||
'Dennis Ritchie',
|
||||
'Eric S. Raymond',
|
||||
'Richard M. Stallman',
|
||||
'DPR',
|
||||
'Sabu',
|
||||
]
|
||||
|
||||
base_system = [
|
||||
'Amiga', 'C-64', 'IBM PC', 'Z80', 'VAX', 'the PDP-8',
|
||||
]
|
||||
|
||||
base_time = [
|
||||
'way back', 'a few years ago', 'in the early 90\'s I think',
|
||||
'when everybody had a(n) <verber>',
|
||||
'before anybody knew who <person> was',
|
||||
]
|
||||
|
||||
# <hack> is intransitive
|
||||
# <tool> is singular
|
||||
|
||||
base_advice = [
|
||||
'Try <hacking>.',
|
||||
'Did you <hack> first?',
|
||||
'Read up on <hacking>.',
|
||||
'Check <service> for a(n) <tool>.',
|
||||
'See if the <tool> has <hacked> already.',
|
||||
'Did you check the <tool> config?',
|
||||
'Hm, sounds like a problem with the <tool>.',
|
||||
'Doesn\'t look like the <tool> is <hacking>.',
|
||||
'Check the "<tool>" wiki.',
|
||||
'You probably didn\'t <hack>.',
|
||||
'Check the "<tool>" website.',
|
||||
'<hack>, then send me the <tool> output.',
|
||||
'Pastebin your <tool> config.',
|
||||
'I think my <noun> has a(n) <verber>, try that.',
|
||||
'<hacking> worked for me.',
|
||||
'Did you enable the <tool>?',
|
||||
'No, the <tool> <hacks>. You want a(n) <tool>.',
|
||||
'Do you have a(n) <tool> installed?',
|
||||
'A(n) <tool> is needed to <hack>.',
|
||||
'<person> claims you can <hack>.',
|
||||
'I heard <person> <hacks> when that happens.',
|
||||
'I saw on <service>, you can <hack>.',
|
||||
'A(n) <tool> might do the trick.',
|
||||
'Make sure to delete your <tool>. That stuff is illegal.',
|
||||
'Did you <hack> before you <hacked>?',
|
||||
'Where did you <verb> the <tool> to?',
|
||||
'I don\'t know. Ask the guy who wrote your <tool>. I think <person>?',
|
||||
'Was this with a(n) <tool> or a(n) <tool>?',
|
||||
'Please use the official <tool>.',
|
||||
'That won\'t work. You can\'t just <hack>.',
|
||||
'<hack>, <hack>, and THEN <hack>. Sheesh.',
|
||||
'No, don\'t <hack>. <person> recently published a CVE about that.',
|
||||
'<verb>, <verb>, <verb>. This is our motto.',
|
||||
'Don\'t think too hard about <hacking>. The <tool> will do that.',
|
||||
'There\'s a(n) <noun> exploit floating around somewhere. Check <service>.',
|
||||
'Simple <tools> cannot <hack>. You need a good, solid <tool>.',
|
||||
'I had a(n) <tool> for <system> <time>.',
|
||||
'Sounds like you need a(n) <tool>. <person> wrote one for <service>.',
|
||||
]
|
||||
|
||||
def simple_get(the_list):
|
||||
def get_thing():
|
||||
return choice(the_list)
|
||||
return get_thing
|
||||
|
||||
get_base_verb = simple_get(base_verb)
|
||||
get_noun = simple_get(base_noun)
|
||||
get_service = simple_get(base_service)
|
||||
get_hack_object = simple_get(base_hack_object)
|
||||
get_tool = simple_get(base_tool)
|
||||
get_tools = simple_get(base_tools)
|
||||
get_person = simple_get(base_person)
|
||||
get_base_advice = simple_get(base_advice)
|
||||
get_system = simple_get(base_system)
|
||||
get_time = simple_get(base_time)
|
||||
|
||||
def get_nouns():
|
||||
n = get_noun()
|
||||
if not n[-1] in string.ascii_letters:
|
||||
return n + '\'s'
|
||||
if n.lower()[-1] in 'xs':
|
||||
return n + 'es'
|
||||
return n + 's'
|
||||
|
||||
def compute_verb(n):
|
||||
v = get_base_verb()
|
||||
base = v[0]
|
||||
ext = v[n]
|
||||
if ext[0] == '-':
|
||||
return base + ext[1:]
|
||||
return ext
|
||||
|
||||
def make_verb(n):
|
||||
def get_verb():
|
||||
return compute_verb(n)
|
||||
return get_verb
|
||||
|
||||
get_verb = make_verb(0)
|
||||
get_verbs = make_verb(1)
|
||||
get_verbed = make_verb(2)
|
||||
get_verber = make_verb(3)
|
||||
get_verbing = make_verb(4)
|
||||
|
||||
def make_hack(vf):
|
||||
def get_hack():
|
||||
return vf() + ' ' + get_hack_object()
|
||||
return get_hack
|
||||
|
||||
def get_hacker():
|
||||
return get_hack_object() + ' ' + get_verber()
|
||||
|
||||
get_hack = make_hack(get_verb)
|
||||
get_hacks = make_hack(get_verbs)
|
||||
get_hacked = make_hack(get_verbed)
|
||||
get_hacking = make_hack(get_verbing)
|
||||
|
||||
index_get = {
|
||||
'verb': get_verb,
|
||||
'verbs': get_verbs,
|
||||
'verbed': get_verbed,
|
||||
'verber': get_verber,
|
||||
'verbing': get_verbing,
|
||||
|
||||
'noun': get_noun,
|
||||
'nouns': get_nouns,
|
||||
|
||||
'hack': get_hack,
|
||||
'hacks': get_hacks,
|
||||
'hacked': get_hacked,
|
||||
'hacker': get_hacker,
|
||||
'hacking': get_hacking,
|
||||
|
||||
'service': get_service,
|
||||
|
||||
'tool': get_tool,
|
||||
'tools': get_tools,
|
||||
|
||||
'person': get_person,
|
||||
'system': get_system,
|
||||
'time': get_time,
|
||||
}
|
||||
|
||||
def can_reduce(s):
|
||||
return '<' in s and '>' in s
|
||||
|
||||
def reduction(s):
|
||||
s = re.split('[<>]', s)
|
||||
for i, word in enumerate(s):
|
||||
if i % 2 == 0:
|
||||
continue
|
||||
up = False
|
||||
if all(x in string.ascii_uppercase for x in word):
|
||||
up = True
|
||||
word = word.lower()
|
||||
if not word in index_get:
|
||||
word = '?' + word
|
||||
else:
|
||||
word = index_get[word]()
|
||||
if up:
|
||||
word = word.upper()
|
||||
s[i] = word
|
||||
return ''.join(s)
|
||||
|
||||
def indefinite_articles(s):
|
||||
s = re.sub('([aA])\\(([nN])\\) ([AEFHILMNORSXaeiou])', '\\1\\2 \\3', s)
|
||||
s = re.sub('([aA])\\([nN]\\) ', '\\1 ', s)
|
||||
return s
|
||||
|
||||
def evaluate(s):
|
||||
while can_reduce(s):
|
||||
s = reduction(s)
|
||||
s = indefinite_articles(s)
|
||||
s = s[0].upper() + s[1:]
|
||||
return s
|
||||
|
||||
def get_advice():
|
||||
return evaluate(get_base_advice())
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) > 1:
|
||||
print(evaluate(sys.argv[1]))
|
||||
else:
|
||||
print(get_advice())
|
||||
|
||||
from util import hook
|
||||
|
||||
@hook.command
|
||||
def hack(inp):
|
||||
res = ""
|
||||
if len(inp) > 1:
|
||||
res = evaluate(inp)
|
||||
else:
|
||||
res = evaluate(get_base_advice())
|
||||
|
||||
return res
|
|
@ -2,29 +2,8 @@ import re
|
|||
|
||||
from util import hook
|
||||
|
||||
|
||||
@hook.command(autohelp=False)
|
||||
def help(inp, bot=None, pm=None):
|
||||
".help [command] -- gives a list of commands/help for a command"
|
||||
|
||||
funcs = {}
|
||||
disabled = bot.config.get('disabled_plugins', [])
|
||||
disabled_comm = bot.config.get('disabled_commands', [])
|
||||
for command, (func, args) in bot.commands.iteritems():
|
||||
fn = re.match(r'^plugins.(.+).py$', func._filename)
|
||||
if fn.group(1).lower() not in disabled:
|
||||
if command not in disabled_comm:
|
||||
if func.__doc__ is not None:
|
||||
if func in funcs:
|
||||
if len(funcs[func]) < len(command):
|
||||
funcs[func] = command
|
||||
else:
|
||||
funcs[func] = command
|
||||
|
||||
commands = dict((value, key) for key, value in funcs.iteritems())
|
||||
|
||||
if not inp:
|
||||
pm('available commands: ' + ' '.join(sorted(commands)))
|
||||
else:
|
||||
if inp in commands:
|
||||
pm(commands[inp].__doc__)
|
||||
pm("Lol, you think there's help. How cute.")
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
from random import choice
|
||||
from util import hook
|
||||
|
||||
quotes = []
|
||||
|
||||
with open("./plugins/data/plinkett.txt", "r") as fin:
|
||||
quotes = fin.readlines()
|
||||
|
||||
@hook.command
|
||||
@hook.regex("^plinkett fact$")
|
||||
def plinkett(inp):
|
||||
return choice(quotes)
|
|
@ -16,23 +16,27 @@ def get_time(ep):
|
|||
def when(inp, say=None):
|
||||
#"Shows the countdown to the new episode of My Little Pony: Friendship is Magic!"
|
||||
|
||||
ep = ponyapi.newest()
|
||||
now, then, td = get_time(ep)
|
||||
seasonep = ""
|
||||
try:
|
||||
ep = ponyapi.newest()
|
||||
now, then, td = get_time(ep)
|
||||
seasonep = ""
|
||||
|
||||
if inp == "discord":
|
||||
return "%s will air on %s" % (ep[u"name"], DDate(then))
|
||||
if inp == "discord":
|
||||
return "%s will air on %s" % (ep[u"name"], DDate(then))
|
||||
|
||||
if ep[u"is_movie"]:
|
||||
seasonep = "(a movie)"
|
||||
else:
|
||||
seasonep = "(season %d episode %d)" % (ep[u"season"], ep[u"episode"])
|
||||
if ep[u"is_movie"]:
|
||||
seasonep = "(a movie)"
|
||||
else:
|
||||
seasonep = "(season %d episode %d)" % (ep[u"season"], ep[u"episode"])
|
||||
|
||||
reply = "%s %s will air on %s in %d days!" % (
|
||||
ep[u"name"], seasonep, then.strftime("%a, %d %b %Y %H:%M:%S"),
|
||||
td.days)
|
||||
reply = "%s %s will air on %s in %d days!" % (
|
||||
ep[u"name"], seasonep, then.strftime("%a, %d %b %Y %H:%M:%S"),
|
||||
td.days)
|
||||
|
||||
return reply
|
||||
return reply
|
||||
|
||||
except:
|
||||
return "404! We're on hiatus!"
|
||||
|
||||
@hook.command
|
||||
def randomep(inp):
|
||||
|
|
|
@ -4,23 +4,35 @@ from util import hook
|
|||
def skeltal(_):
|
||||
return "https://www.youtube.com/watch?v=10pqeNBg5d0"
|
||||
|
||||
@hook.regex(r"^([hH])(|[?!])$")
|
||||
@hook.regex(r"^([hH])([?!]*)$")
|
||||
def h(inp, channel=None, conn=None):
|
||||
suff = ""
|
||||
if inp.group(2) == "?":
|
||||
suff = "!"
|
||||
elif inp.group(2) == "!":
|
||||
suff = "?"
|
||||
if inp.group(2).startswith("?"):
|
||||
suff = inp.group(2).replace("?", "!")
|
||||
elif inp.group(2).startswith("!"):
|
||||
suff = inp.group(2).replace("!", "?")
|
||||
return inp.group(1) + suff
|
||||
|
||||
@hook.regex(r"^(|press )([xfh]) to pay respects$")
|
||||
def pay_respects(inp):
|
||||
return inp.group(2)
|
||||
|
||||
@hook.regex("dQw4w9WgXcQ")
|
||||
def rickrollProtector(inp):
|
||||
return "linked a rick roll, watch out"
|
||||
|
||||
@hook.regex("[kK]-[lL]ine")
|
||||
def kline(inp):
|
||||
return "http://i.imgur.com/FQjQgyB.jpg"
|
||||
return "https://i.imgur.com/FQjQgyB.jpg"
|
||||
|
||||
@hook.command
|
||||
def botsnack(inp):
|
||||
return ":D"
|
||||
|
||||
@hook.command
|
||||
def debian_init(inp):
|
||||
return "part 1: http://aceattorney.sparklin.org/player.php?trial_id=57684"
|
||||
|
||||
@hook.regex("^i kno u r but wat am i >:P$")
|
||||
def gay(inp):
|
||||
return "gay"
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
import math
|
||||
import time
|
||||
|
||||
from util import hook, urlnorm, timesince
|
||||
|
||||
|
||||
expiration_period = 60 * 60 * 24 # 1 day
|
||||
|
||||
ignored_urls = [urlnorm.normalize("http://google.com")]
|
||||
|
||||
|
||||
def db_init(db):
|
||||
db.execute("create table if not exists urlhistory"
|
||||
"(chan, url, nick, time)")
|
||||
db.commit()
|
||||
|
||||
|
||||
def insert_history(db, chan, url, nick):
|
||||
db.execute("insert into urlhistory(chan, url, nick, time) "
|
||||
"values(?,?,?,?)", (chan, url, nick, time.time()))
|
||||
db.commit()
|
||||
|
||||
|
||||
def get_history(db, chan, url):
|
||||
db.execute("delete from urlhistory where time < ?",
|
||||
(time.time() - expiration_period,))
|
||||
return db.execute("select nick, time from urlhistory where "
|
||||
"chan=? and url=? order by time desc", (chan, url)).fetchall()
|
||||
|
||||
|
||||
def nicklist(nicks):
|
||||
nicks = sorted(dict(nicks), key=unicode.lower)
|
||||
if len(nicks) <= 2:
|
||||
return ' and '.join(nicks)
|
||||
else:
|
||||
return ', and '.join((', '.join(nicks[:-1]), nicks[-1]))
|
||||
|
||||
|
||||
def format_reply(history):
|
||||
if not history:
|
||||
return
|
||||
|
||||
last_nick, recent_time = history[0]
|
||||
last_time = timesince.timesince(recent_time)
|
||||
|
||||
if len(history) == 1:
|
||||
return "%s linked that %s ago." % (last_nick, last_time)
|
||||
|
||||
hour_span = math.ceil((time.time() - history[-1][1]) / 3600)
|
||||
hour_span = '%.0f hours' % hour_span if hour_span > 1 else 'hour'
|
||||
|
||||
hlen = len(history)
|
||||
ordinal = ["once", "twice", "%d times" % hlen][min(hlen, 3) - 1]
|
||||
|
||||
if len(dict(history)) == 1:
|
||||
last = "last linked %s ago" % last_time
|
||||
else:
|
||||
last = "last linked by %s %s ago" % (last_nick, last_time)
|
||||
|
||||
return "that url has been posted %s in the past %s by %s (%s)." % (ordinal,
|
||||
hour_span, nicklist(history), last)
|
||||
|
||||
|
||||
@hook.regex(r'([a-zA-Z]+://|www\.)[^ ]+')
|
||||
def urlinput(match, nick='', chan='', db=None, bot=None):
|
||||
db_init(db)
|
||||
url = urlnorm.normalize(match.group().encode('utf-8'))
|
||||
if url not in ignored_urls:
|
||||
url = url.decode('utf-8')
|
||||
history = get_history(db, chan, url)
|
||||
insert_history(db, chan, url, nick)
|
||||
|
||||
inp = match.string.lower()
|
||||
|
||||
for name in dict(history):
|
||||
if name.lower() in inp: # person was probably quoting a line
|
||||
return # that had a link. don't remind them.
|
||||
|
||||
if nick not in dict(history):
|
||||
return format_reply(history)
|
Loading…
Reference in New Issue