Ported banterbot to pinhook framework and some other changes

This commit is contained in:
RussellChamp committed 2019-01-25 11:16:19 -05:00
1 parent 0627b4a9e3
commit bc102890b2
39 files changed
+1629 -507

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import pinhook.plugin
from util import acronymFinder
@pinhook.plugin.register('!acronym')
def acronym_plugin(msg):
return pinhook.plugin.message(acronymFinder.get_acros(msg.arg, True, True))
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/python3
import pinhook.plugin
from util import defineWord
@pinhook.plugin.register('!define')
def define_plugin(msg):
if not msg.arg:
return pinhook.plugin.message("{}: No word given".format(msg.nick))
word = msg.arg.split()[0]
defs = defineWord.defWord(word)
if not defs:
return pinhook.plugin.message("{}: Couldn't find the definition of '{}' :(".format(msg.nick, word))
elif isinstance(defs, list):
return pinhook.plugin.message("\n".join(["{} : Define '{}' {}".format(msg.nick, word, entry) for entry in defs]))
else:
return pinhook.plugin.message("{} : Define '{}' {}".format(msg.nick, word, defs))
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import pinhook.plugin
from util import evil
@pinhook.plugin.register('!evil')
def evil_plugin(msg):
return pinhook.plugin.message(evil.get_thing())
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import pinhook.plugin
@pinhook.plugin.listener('fight')
def fight_plugin(msg):
if msg.botnick + ": " in msg.text:
return pinhook.plugin.message("u want some of this, m8?")
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/python3
import pinhook.plugin
import subprocess
import time
@pinhook.plugin.register('!figlet')
def figlet_plugin(msg):
if not msg.arg:
return pinhook.plugin.message("No text given. :(")
else:
lines = subprocess.Popen(
["figlet", "-w140"] + msg.arg.split(" "), shell=False, stdout=subprocess.PIPE
).stdout.read().decode("utf-8")
for line in lines.split("\n"):
msg.privmsg(msg.channel, line)
time.sleep(0.4) # to avoid channel throttle due to spamming
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/python3
import pinhook.plugin
from util import newBanter
@pinhook.plugin.register('!newbanter')
def newbanter_plugin(msg):
try:
args = msg.arg.split()
banter = newBanter.getBanter(*args)
if banter == "":
text = "{}: Could not find any new banter".format(msg.nick)
if len(args) >= 1:
text += " using munge word '{}'. Try something else?".format(args[0])
return pinhook.plugin.message(text)
else:
return pinhook.plugin.message("{}: Here, why don't you try '{}'?".format(msg.nick, banter))
except FileNotFoundError as e: # this happens if you attempt to search a word dict that doesn't exist
text = "{}: Could not find word dictionary".format(msg.nick)
if len(args) >= 2:
text += " '{}'. Maybe try another one?".format(args[1])
return pinhook.plugin.message(text)
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/python3
import pinhook.plugin
@pinhook.plugin.register('!notice')
def notice_plugin(msg):
msg.notice(msg.nick, "Notice me senpai!")
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/python3
import pinhook.plugin
import random
@pinhook.plugin.register('!rainbow')
def rainbow_plugin(msg):
word = msg.arg or "RAINBOW"
output = ""
rb = ["5", "7", "8", "3", "12", "13", "6"]
bg = "01"
idx = random.randrange(0, len(rb))
for l in word:
if l == " ":
output += " "
else:
output += "\x03" + rb[idx % len(rb)] + "," + bg + l
idx += 1
return pinhook.plugin.message(output)
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/python3
import pinhook.plugin
from util import rhymesWith
poetic_file = "/home/nossidge/poems/words_poetic.txt"
@pinhook.plugin.register('!rhymes')
def rhymes_plugin(msg):
word = ""
if msg.arg == "":
with open(poetic_file, "r") as words:
word = random.choice(words.readlines()).strip("\n")
else:
word = msg.arg.split()[0]
rhymes = rhymesWith.rhymeZone(word)
if len(rhymes) == 0:
return pinhook.plugin.message("{}: Couldn't find anything that rhymes with '{}' :(".format(msg.nick, word))
else:
return pinhook.plugin.message("{}: Here, these words rhyme with '{}': {}".format(msg.nick, word, ", ".join(rhymes)))
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/python3
import pinhook.plugin
@pinhook.plugin.register('!rollcall')
def rollcall_plugin(msg):
text = "U wot m8? I score all the top drawer #banter and #bantz on this channel! / Find new top-shelf banter with !newbanter [mungeWord [dictionary]], !rhymes, and !define."
text += "\nLook up things with !acronym and !whosaid / Make your chatter #legend with !rainbow, !toilet, and !figlet."
text += "\nFind interesting things with !xkcd and !wiki-philosophy / Get jokes with !welch !evil !kjp and !help"
return pinhook.plugin.message(text)
@@ -0,0 +1,10 @@
#!/usr/bin/python3
import pinhook.plugin
from util import banter
@pinhook.plugin.listener('banter')
def banter_plugin(msg):
if "#banter" in msg.text.lower() or "#bantz" in msg.text.lower():
message = banter.score_banter(msg.nick, msg.text)
return pinhook.plugin.message(message)
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/python3
import pinhook.plugin
@pinhook.plugin.register('!')
def _plugin(msg):
return pinhook.plugin.message()
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/python3
import pinhook.plugin
import subprocess
import time
@pinhook.plugin.register('!toilet')
def toilet_plugin(msg):
if not msg.arg:
return pinhook.plugin.message("No text given. :(")
else:
lines = subprocess.Popen(
["toilet", "-w140", "-F", "crop", "--irc"] + msg.arg.split(" "),
shell=False,
stdout=subprocess.PIPE,
).stdout.read().decode("utf-8")
for line in lines.split("\n"):
msg.privmsg(msg.channel, line)
time.sleep(0.4) # to avoid channel throttle due to spamming
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/python3
import pinhook.plugin
from util import tumblr
@pinhook.plugin.register('!kjp')
def kjp_plugin(msg):
return pinhook.plugin.message(tumblr.tumble("http://kingjamesprogramming.tumblr.com"))
@pinhook.plugin.register('!help')
def help_plugin(msg):
return pinhook.plugin.message(tumblr.tumble("http://thedoomthatcametopuppet.tumblr.com"))
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import pinhook.plugin
@pinhook.plugin.register('!water')
def water_plugin(msg):
if msg.botnick in msg.arg:
return pinhook.plugin.message("Fight me, {}!".format(msg.nick))
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import pinhook.plugin
from util import welch
@pinhook.plugin.register('!welch')
def welch_plugin(msg):
return pinhook.plugin.message(welch.get_thing())
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import pinhook.plugin
from util import whoSaid
@pinhook.plugin.register('!whosaid')
def whosaid_plugin(msg):
return pinhook.plugin.message(whoSaid.whoSaid(msg.arg))
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/python3
import pinhook.plugin
from util import wikiphilosophy
@pinhook.plugin.register('!wphilosophy')
def wiki_philosophy_plugin(msg):
msg.privmsg(msg.channel, "Ok, give me a minute while I look up '{}'".format(msg.arg))
steps = wikiphilosophy.get_philosophy_lower(msg.arg)
if not steps:
return pinhook.plugin.message("Couldn't find a wikipedia entry for {}".format(msg.arg))
else:
joined_steps = " > ".join(steps)
if steps[-1] == "Philosophy":
joined_steps += "!!!"
for line in [ joined_steps[i : i + 400] for i in range(0, len(joined_steps), 400) ]:
msg.privmsg(msg.channel, line)
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import pinhook.plugin
from util import xkcdApropos
@pinhook.plugin.register('!xkcd')
def xkcd_plugin(msg):
return pinhook.plugin.message(xkcdApropos.xkcd(msg.arg))