Update things, delete things, add things

This commit is contained in:
RussellChamp committed 2019-03-15 10:20:44 -04:00
1 parent 772995c0ff
commit a8b397a44f
31 files changed
+347 -803

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
These are some bots that I've written using the pinhook framework
* banterbot
* tildebot
* topicbot
* madlibbot
* numberwangbot
Bots are kicked off by the generic bot_launcher.py through systemd services.
You could also write a manual script that encapsulates these config options.
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import pinhook.plugin
@pinhook.plugin.register('!botlist')
def rollcall_plugin(msg):
text = "I am owned and run by {}".format(",".join(msg.ops))
return pinhook.plugin.message(text)
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/python3
import pinhook.plugin
import util.fightCrime
@pinhook.plugin.register('!crime')
def crime_plugin(msg):
message = util.fightCrime.getDuo()
return pinhook.plugin.message(message)
+7
View File
@@ -1,8 +1,15 @@
#!/usr/bin/python3
import pinhook.plugin
import time
@pinhook.plugin.listener('fight')
def fight_plugin(msg):
if msg.botnick + ": " in msg.text:
return pinhook.plugin.message("u want some of this, m8?")
@pinhook.plugin.listener('action')
def action_plugin(msg):
if msg.botnick in msg.text and hasattr(msg, 'event') and msg.event is "action":
time.sleep(1)
msg.action(msg.channel, msg.text.replace(msg.botnick, msg.nick) + " back")
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/python3
import pinhook.plugin
@pinhook.plugin.register('!help2')
def help_plugin(msg):
# just a placeholder to overload the built-in !help function
if msg.nick in msg.ops:
return pinhook.plugin.message("!help has been disabled")
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import pinhook.plugin
from util import randomThings
@pinhook.plugin.register('!random')
def acronym_plugin(msg):
return pinhook.plugin.message(randomThings.getRandom(msg.arg))
+1
View File
@@ -1,6 +1,7 @@
#!/usr/bin/python3
import pinhook.plugin
import random
from util import rhymesWith
poetic_file = "/home/nossidge/poems/words_poetic.txt"
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/python3
import pinhook.plugin
import util.chopra
@pinhook.plugin.register('!wisdom')
def wisdom_plugin(msg):
message = util.chopra.getWisdom()
return pinhook.plugin.message(message)
+4
View File
@@ -1,5 +1,9 @@
#!/usr/bin/python3
# This is a generic launcher that acts as a chasis for various bots
# I would recomend creating a separate script that can be invoked
# directly for each bot you run
import argparse
from pinhook.bot import Bot
+1 -1
View File
@@ -1 +1 @@
35
4
+37 -28
View File
@@ -1,8 +1,8 @@
krowbar&^%2745&^%1548770703.413761
krowbar&^%2854&^%1552509758.872889
karlen&^%498&^%1527613440
endorphant&^%809&^%1444775660
jumblesale&^%25&^%1426171214
marcus&^%2578&^%1538071912
marcus&^%2578&^%1549650312.011321
papa&^%181&^%1474509971
epicmorphism&^%15&^%1546280322
audy&^%83&^%1504564254
@@ -40,9 +40,9 @@ xkeeper&^%201&^%1539193279
cosnok&^%807&^%1508878859
escobar&^%1&^%1475431401
amicabot&^%30&^%1481225205
caff&^%1030&^%1540040705
caff&^%1032&^%1552346661.160125
kadin&^%19&^%1541514839
desvox&^%59&^%1548198585
desvox&^%69&^%1551716946.90284
mankins&^%3&^%1480211581
cinch&^%2&^%1480454755
caffbot&^%969&^%1532662872
@@ -50,14 +50,14 @@ evilbot&^%4&^%1480693919
tybaltcat&^%7&^%1481076625
Minerbot&^%328&^%1548433782
mio&^%347&^%1529720473
tehfraga&^%673&^%1547260565
tehfraga&^%811&^%1552634200.805025
sushi&^%10&^%1493253212
troido&^%303&^%1548409580
gamebot&^%336&^%1548409599
nilaky&^%1759&^%1548459568
gamebot&^%419&^%1552404970.041536
nilaky&^%1968&^%1552624002.376977
bucket&^%103&^%1507931139
lolbot&^%1&^%1502568407
m455&^%12&^%1512076715
m455&^%12&^%1550095510.913918
abraxas&^%3&^%1500665540
nilakybot&^%7&^%1503006301
greely&^%70&^%1509386334
@@ -67,9 +67,9 @@ pinhook&^%8&^%1509744722
emfor&^%3&^%1509671353
k2l8m11n2&^%11&^%1510932395
sacredpixel&^%3&^%1522082931
login&^%3276&^%1548698114
login&^%3669&^%1552632831.452062
kelpiebot&^%3&^%1513101957
unreal&^%2&^%1534387108
unreal&^%4&^%1550140674.610166
kinsey&^%26&^%1520446672
testgameb&^%2&^%1537604954
erin&^%2&^%1517681999
@@ -77,14 +77,14 @@ wuz&^%3&^%1518125300
hashdang&^%4&^%1518666906
ubergeek&^%63&^%1530410162
silver&^%9&^%1519333029
equa&^%53&^%1534373756
equa&^%94&^%1552602770.059508
audiodude&^%2&^%1519453927
whimsy&^%47&^%1529678733
wangofett&^%286&^%1548446486
wangofett&^%294&^%1552436276.341388
saturn&^%3&^%1521429369
lucidiot&^%28&^%1526201925
tracer&^%1&^%1521744878
jan6&^%1359&^%1548771222.440076
jan6&^%1396&^%1550244555.585356
eeeeeta&^%55&^%1540361066
cmccabe&^%81&^%1529698164
carbon&^%9&^%1524135505
@@ -93,10 +93,10 @@ Halian&^%32&^%1528360263
lunasspecto&^%4&^%1524164784
severak&^%17&^%1546438400
ralph&^%4&^%1526980620
von&^%490&^%1548233084
von&^%497&^%1551951799.571028
ensis&^%1750&^%1546853217
simon&^%26&^%1527937489
benharri&^%3276&^%1548695613
benharri&^%3744&^%1552656758.814522
cpb&^%3&^%1528930564
calmbit&^%160&^%1541625694
wisebot&^%5652&^%1539612163
@@ -105,37 +105,46 @@ ninlenna&^%6&^%1531186900
x4464&^%1&^%1532028546
pounce&^%19&^%1532133325
livix&^%7&^%1533603142
ben&^%3&^%1533767627
npa&^%326&^%1548659103
ben&^%3&^%1551976138.688011
npa&^%467&^%1552622753.295706
ezo&^%6&^%1533883842
aliasless&^%36&^%1541001821
kirch&^%492&^%1548773313.169501
kirch&^%717&^%1552517847.310872
root&^%2&^%1535558514
byte&^%5&^%1536416308
qbe&^%7&^%1537850181
informativeheck&^%3&^%1536733938
h00fi&^%1&^%1537050053
fantoro&^%57&^%1542125611
fantoro&^%59&^%1550270271.196303
tildethief&^%7421&^%1542132794
benjaminwil&^%581&^%1548377274
deltawitch&^%3453&^%1548462217
archangelic&^%484&^%1541101297
diodelass&^%3&^%1539382302
minerobber&^%420&^%1548433750
benjaminwil&^%612&^%1552337192.892643
deltawitch&^%3551&^%1552602506.535836
archangelic&^%492&^%1551543505.698955
diodelass&^%11&^%1550243960.964821
minerobber&^%424&^%1550645545.053616
brendantcc&^%3&^%1539908223
dozens&^%21&^%1541090333
bowlercaptain&^%6&^%1540926135
nicole&^%6&^%1541276844
littlebigly&^%49&^%1541283119
ahriman&^%636&^%1548663037
tunas&^%114&^%1545848648
ahriman&^%808&^%1552634685.217617
tunas&^%115&^%1551455658.637688
netscape_navigator&^%5&^%1545846867
roan&^%5&^%1545846612
ckipp01&^%3&^%1545813774
ben&^%3&^%1545800958
ben&^%4&^%1551976138.688011
l0010o0001l&^%3&^%154529473
rgdrake&^%1&^%1546086404
handyc&^%5&^%1546456002
fosslinux&^%10&^%1548661962
fosslinux&^%37&^%1550379331.325722
banterbot&^%3&^%1547588758
testgamebot&^%4&^%1547722176
minerobber2&^%56&^%1552364229.599098
minerbot&^%113&^%1552404981.997855
desvox__&^%2&^%1549262081.083705
roy&^%121&^%1551697915.426383
diodelasses&^%19&^%1551139645.230519
asdf&^%47&^%1552038120.672267
Kneezle&^%1&^%1551975324.060361
strdg&^%2&^%1551967813.490182
kneezle&^%6&^%1552213173.813114
-113
View File
@@ -1,113 +0,0 @@
#!/usr/bin/python
# http://wiki.shellium.org/w/Writing_an_IRC_bot_in_Python
# Import some necessary libraries.
import socket
import os
import sys
from optparse import OptionParser
import util
parser = OptionParser()
parser.add_option(
"-s",
"--server",
dest="server",
default="127.0.0.1:6667",
help="the server to connect to",
metavar="SERVER",
)
parser.add_option(
"-c",
"--channel",
dest="channel",
default="#tildetown",
help="the channel to join",
metavar="CHANNEL",
)
parser.add_option(
"-n",
"--nick",
dest="nick",
default="quotebot",
help="the nick to use",
metavar="NICK",
)
(options, args) = parser.parse_args()
def random_quote(channel):
quote = os.popen("/home/frs/quotes/randquote.py").read()
if len(quote) >= 256:
quote = quote[:253] + "..."
util.sendmsg(ircsock, channel, quote)
def haiku(channel):
h = os.popen("haiku").read().replace("\n", " // ")
util.sendmsg(ircsock, channel, h)
def say_mentions(user, message):
nick = util.get_user_from_message(message)
menschns = (
os.popen("/home/karlen/bin/mensch -u {} -t 24 -z +0".format(user))
.read()
.replace("\t", ": ")
.split("\n")
)
for mention in menschns:
if not "" == mention:
toSend = "PRIVMSG " + nick + " :" + mention + "\n"
if len(toSend) >= 256:
toSend = toSend[:253] + "..."
ircsock.send(toSend)
def say_chatty(channel):
chattyOut = os.popen("/home/karlen/bin/chatty").read().split("\n")
for line in chattyOut:
if line:
util.sendmsg(ircsock, channel, line)
def listen():
while 1:
ircmsg = ircsock.recv(2048).decode("utf-8")
ircmsg = ircmsg.strip("\r\n")
formatted = util.format_message(ircmsg)
if "" == formatted:
continue
print(formatted)
user = formatted.split("\t")[1]
if ircmsg.find(":!quote") != -1:
random_quote(options.channel)
if ircmsg.find(":!mentions") != -1:
say_mentions(user, ircmsg)
if ircmsg.find(":!chatty") != -1:
say_chatty(options.channel)
if ircmsg.find(":!haiku") != -1:
haiku(options.channel)
if ircmsg[:4] == "PING":
util.ping(ircsock, ircmsg)
sys.stdout.flush()
# time.sleep(1)
ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
util.connect(ircsock, options)
listen()
+2 -2
View File
@@ -2,8 +2,8 @@
# check if the bot is already running
if [[ ! `pidof -sx bot_launcher.py` || ! `ps -p $(pidof -sx bot_launcher.py) -o args | grep "\-n banterbot"` ]]; then
echo "Starting banterbot"
/home/krowbar/Code/irc/bot_launcher.py -n banterbot -s 127.0.0.1 -p 6667 -c \#tildetown \#bots
# nohup /home/krowbar/Code/irc/bot_launcher.py -n banterbot -s 127.0.0.1:6667 -c \#bot_test
#/home/krowbar/Code/irc/bot_launcher.py -n banterbot -s 127.0.0.1 -p 6667 -c \#tildetown \#bots
/home/krowbar/Code/irc/bot_launcher.py -n banterbot -s 127.0.0.1 -p 6667 -c \#bots
else
echo "Banterbot has already been started"
fi
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=banterbot daemon
After=banterbot.service
[Service]
Type=simple
ExecStart=/home/krowbar/Code/irc/bot_launcher.py -s 127.0.0.1 -p 6667 -n banterbot -c #tildetown #bots
WorkingDirectory=/home/krowbar/Code/irc/
Restart=always
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=default.target
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=madlibbot daemon
After=madlibbot.service
[Service]
Type=simple
ExecStart=/home/krowbar/Code/irc/madlibbot/madlibbot.py -s 127.0.0.1:6667 -n madlibbot -c #bots #madlibs
WorkingDirectory=/home/krowbar/Code/irc/
Restart=always
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=default.target
+1 -1
View File
@@ -4,7 +4,7 @@ After=tildebot.service
[Service]
Type=simple
ExecStart=/home/krowbar/Code/irc/tildebot.py -n tildebot -c \#tildetown
ExecStart=/home/krowbar/Code/irc/bot_launcher.py -n tildebot -s 127.0.0.1 -p 6667 -c #bots
WorkingDirectory=/home/krowbar/Code/irc/
Restart=always
RestartSec=5
+15
View File
@@ -0,0 +1,15 @@
[Unit]
Description=topicbot daemon
After=topicbot.service
[Service]
Type=simple
ExecStart=/home/krowbar/Code/irc/banterbot.py -s 127.0.0.1 -p 6667 -n topicbot -c #bot_test
WorkingDirectory=/home/krowbar/Code/irc/
Restart=always
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=default.target
+69
View File
@@ -0,0 +1,69 @@
#!/usr/bin/python3
# This is a generic launcher that acts as a chasis for various bots
# I would recomend creating a separate script that can be invoked
# directly for each bot you run
import argparse
from pinhook.bot import Bot
parser = argparse.ArgumentParser()
parser.add_argument(
"-s",
"--server",
dest="server",
default="127.0.0.1",
help="the server to connect to",
metavar="SERVER",
)
parser.add_argument(
"-p",
"--port",
dest="port",
type=int,
default=6667,
help="the port to connect to",
metavar="PORT",
)
parser.add_argument(
"-c",
"--channels",
dest="channels",
nargs="+",
default=["#bot_test"],
help="the channels to join",
metavar="CHANNELS",
)
parser.add_argument(
"-n",
"--nick",
dest="nick",
default="banterbot",
help="the nick to use",
metavar="NICK",
)
parser.add_argument(
"-o",
"--owners",
dest="owners",
nargs="+",
default=["krowbar"],
help="the owners of this bot",
metavar="OWNERS",
)
args = parser.parse_args()
print(args)
bot = Bot(
channels = args.channels,
nickname = args.nick,
ops = args.owners,
plugin_dir = "{}_plugins".format(args.nick),
server = args.server,
port = args.port
)
if __name__ == "__main__":
bot.start()
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
def getWisdom():
url = "http://www.wisdomofchopra.com/iframe.php"
html = BeautifulSoup(requests.get(url).content, "html.parser")
return html.find("td", { "id": "quote" }).text
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
def getDuo():
url = "https://www.theyfightcrime.org/"
html = BeautifulSoup(requests.get(url).content, "html.parser")
return html.findAll('p')[1].text
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
def ReionizeElectrons():
url = "http://sebpearce.com/bullshit/"
html = BeautifulSoup(requests.get(url).content, "html.parser")
return html.findAll('p')[1].text
+14 -4
View File
@@ -6,22 +6,32 @@ import random
import re
quotefile = "/home/karlen/irc/quotes.txt"
wordsfile = "/usr/share/dict/words"
chuckfile = "/home/krowbar/Code/irc/data/chuck.txt"
chuckApi = "https://api.icndb.com/jokes/random"
def get_quote():
quotes = open(quotefile, "r").read().split("---")
quote, attr = random.choice(quotes).strip().splitlines()
attempt = 10
dict_words = open(wordsfile).read().split()
while True:
good_words = [w for w in quote.split() if w in dict_words and len(w) > 2]
if len(good_words) > 3 or attempt is 0:
break #either we got a good one or we gave up
quote, attr = random.choice(quotes).strip().splitlines()
attempt = attempt - 1
quote = quote[:200] # get only the first 200 chars
word = random.choice([q for q in quote.split(" ") if len(q) > 1])
word = random.choice([q for q in quote.split() if len(q) > 2 and q in dict_words] or [q for q in quote.split() if len(q) > 1])
quote = quote.replace(word, re.sub(r"[a-zA-Z]", "_", word))
return [word, 'Fill in the blank: "' + quote + '" ' + attr]
return [word, 'Fill in the blank: "{}" {}'.format(quote, attr)]
def get_chuck():
#chucks = open(chuckfile, "r").readlines()
#chuck = random.choice(chucks).rstrip()[:200] # get only the first 200 chars
# ha ha! let's see if we can confus login
# ha ha! let's see if we can confuse login
chuck = json.loads(requests.get(chuckApi).content.decode())['value']['joke'][:200]
word = random.choice([w for w in chuck.split(" ") if len(w) > 1 and w.lower() != "chuck" and w.lower() != "norris"])
chuck = chuck.replace(word, re.sub(r"[a-zA-Z]", "_", word)).replace(""", "\"")
return [word, 'Fill in the blank: "{}"'.format(chuck)]
return [word, 'Fill in the blank: "{}"'.format(chuck)]
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/python3
import json
import random
import requests
def getRandom(query = "randomlists"):
query = query.lower().replace(' ', '-')
message = ""
request = requests.get("https://www.randomlists.com/data/{}.json".format(query))
if request.status_code == 404:
request = requests.get("https://www.randomlists.com/data/random-{}.json".format(query))
if request.status_code == 404:
message = "No results found. Try"
request = requests.get("https://www.randomlists.com/data/randomlists.json")
jdata = json.loads(request.content)
items = list()
if 'RandL' in jdata:
items = list(jdata['RandL']['items'])
elif 'data' in jdata:
items = list(jdata['data'])
item = random.choice(items)
if 'name' in item:
message += " " + item['name']
if 'detail' in item:
message += ": " + item['detail']
if 'subtle' in item:
message += " (" + item['subtle'] + ")"
if message == "":
message = item
return message.strip()
+37 -7
View File
@@ -2,6 +2,7 @@
# Import some necessary libraries.
import random
import re
import inflect
import util.puzzle
@@ -58,7 +59,13 @@ def get_negative():
"Not quite",
"Not even close",
"Not for you",
"I think not"
"I think not",
"Wait... uh maybe?",
"It could have been",
"It should have been",
"Whoops",
"SegFault: Insufficient Tildes",
"Wait, what did you guess?"
]
)
@@ -83,6 +90,8 @@ def get_superlative(score):
"worth twice their weight in gold",
"the hero we need",
"no ordinary townie",
"the bot whisperer",
"probably predicting rng",
]
)
elif score > 2:
@@ -95,13 +104,18 @@ def get_superlative(score):
"radical",
"intense",
"pretty lucky",
"knows the territory",
"has what it takes",
"has mad skillz",
#"knows the territory",
#"has what it takes",
#"has mad skillz",
"going the distance",
"a hard worker",
"my sunshine",
"ready to rumble",
"better than sliced bread",
"main protagonist material",
"right as rain",
"a puzzle prophet",
"a counter-captcha expert",
]
)
else:
@@ -120,6 +134,13 @@ def get_superlative(score):
"probably not a robot",
"valuable to the team",
"now trending",
"on your way up",
"credit to team",
"a net positive",
"groovy",
"competent",
"not wrong",
"on the right track",
]
)
@@ -167,6 +188,7 @@ def get_bad_thing():
"actually answered the last question",
"has their pants on backwards",
"forgot their own name",
"got me really confused"
]
)
@@ -264,6 +286,16 @@ def challenge(channel, user, time):
challenges[user] = challenge[1:]
return "{}: {}".format(user, challenge[0])
def valid_answer(answer, guess):
guess = guess.lower();
if callable(answer):
return answer(guess)
else:
# convert the guess and answer to just alphanumeric values. some
# "answers" acidentally have punctuation or other things in them
guess = re.sub(r'\W+', '', guess)
answer = re.sub(r'\w+', '', str(answer).lower())
return (msg == answer or msg == p.number_to_words(answer))
def challenge_response(user, time, msg):
global challenges
@@ -271,9 +303,7 @@ def challenge_response(user, time, msg):
response = ""
if user in challenges:
answer, bonus = challenges[user]
if (callable(answer) and answer(msg.lower())) or (
msg.lower() == str(answer).lower() or msg == p.number_to_words(answer)
):
if valid_answer(answer, msg):
response = give_tilde(user, time, True, bonus)
else:
response = give_tilde(user, time, False, 0)
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
# These seem to get the same result each time we run them. I think TVTropes
# has some anti-scraping mechanism
def getTrope():
url = "https://tvtropes.org"
html = BeautifulSoup(requests.get(url).content, "html.parser")
return url + html.find('a', { 'class': 'button-random-trope' })['href']
def getMedia():
url = "https://tvtropes.org"
html = BeautifulSoup(requests.get(url).content, "html.parser")
return url + html.find('a', { 'class': 'button-random-media' })['href']