Just some recent changes

This commit is contained in:
RussellChamp committed 2018-09-19 17:04:38 +00:00
1 parent ce32bc223b
commit 9247e2f2e2
20 files changed
+243 -88

No files matched your search

+16 -2
View File
@@ -187,7 +187,7 @@ def figlet(channel, text):
lines = subprocess.Popen(["figlet", "-w140"] + text.split(' '), shell=False, stdout=subprocess.PIPE).stdout.read()
for line in lines.split('\n'):
ircsock.send("PRIVMSG " + channel + " :" + line + "\n")
time.sleep(0.3) #to avoid channel throttle due to spamming
time.sleep(0.4) #to avoid channel throttle due to spamming
def toilet(channel, text):
if not text:
@@ -196,7 +196,7 @@ def toilet(channel, text):
lines = subprocess.Popen(["toilet", "-w140", "--irc"] + text.split(' '), shell=False, stdout=subprocess.PIPE).stdout.read()
for line in lines.split('\n'):
ircsock.send("PRIVMSG " + channel + " :" + line + "\n")
time.sleep(0.3) #to avoid channel throttle due to spamming
time.sleep(0.4) #to avoid channel throttle due to spamming
def get_acronym(channel, text):
if not text:
@@ -223,6 +223,13 @@ def get_whosaid(channel, text):
msg += ' and %s said it %d times' % (result['data'][1][0], result['data'][1][1])
ircsock.send("PRIVMSG " + channel + " :" + msg + ".\n")
def get_notice(user, channel):
ircsock.send("CNOTICE " + user + " " + channel + " :Notice me sempai!\n")
def get_water(user, channel, msg, botnick):
if msg.find(botnick) == 0:
ircsock.send("PRIVMSG " + channel + " :Fight me, " + user + "!\n")
def mug_off(channel):
ircsock.send("PRIVMSG " + channel + " :u want some of this, m8?\n")
@@ -317,6 +324,13 @@ def listen(botnick):
if ircmsg.find(":!whosaid") != -1:
get_whosaid(channel, messageText[9:])
if ircmsg.find(":!notice") != -1:
get_notice(user, channel)
if ircmsg.find(":!water") != -1:
get_water(user, channel, messageText[7:], botnick)
if ircmsg.find(":!rollcall") != -1:
rollcall(channel)
+5 -4
View File
@@ -40,7 +40,8 @@ and continue asking for word replacement until it runs out of words to replace.
* Allow story writers the ability to specify that a single answer should be used multiple times in a story
* Maybe specified like {{#a noun#}} or {{#a noun#4}}
* Create word-munging options that can be specified for a word to modify given user input
* Capital - convert "foo" to "Foo"
* AllCaps - convert "bar" to "BAR"
* Numeric - convert "3" to "three"
* Ordinal - convert "3" to "third"
* title - convert "foo" to "Foo"
* upper - convert "bar" to "BAR"
* lower - convert "bAz" to "baz"
* numeric - convert "3" to "three"
* ordinal - convert "3" to "third"
+46 -5
View File
@@ -1,12 +1,16 @@
#!/usr/bin/python
import collections
import glob
import inflect
import random
import re
p = inflect.engine()
file_pattern = "/home/*/madlibs/*.madlib"
file_regex = re.compile(r'^/home/(.*?)/.*/([^/]*)\.madlib$')
word_regex = re.compile(r'{{(.*?)}}')
word_regex = re.compile(r'{{(.*?)(#.*?)?(\|.*)?}}')
word_replace_regex = re.compile(r'^(.*)#(\d*)$')
# Take a file path and return a tuple with the title and original path
def munge_story(file_name):
@@ -25,7 +29,16 @@ def find_stories(limit=999, shuffle=False):
# Count the number of replacable words in the story
def count_words(story):
return len(word_regex.findall(story))
# words that have a '#' part and match should only be counted once
count = 0
repeats = []
for match in re.finditer(word_regex, story):
if match.group(2) is None: #the '#' part
count += 1
elif match.group(1) + match.group(2) not in repeats:
count += 1
repeats.append(match.group(1) + match.group(2))
return count
# Count the number of replacable words in the story when given a file path
def count_words_file(storyPath):
@@ -45,10 +58,38 @@ def find_next_word(story, rand=False):
return (match.group(0), match.group(1))
# Replace a word and return the entire story body
# Using a query phrase, replace a word and return the entire story body
def replace_word(story, query, word):
return story.replace(query, word, 1)
#return re.sub(query, word, story, 1)
rquery = word_regex.search(query)
# '{{foo#bar|baz|bang}}' => ('foo', '#bar', '|baz|bang')
pipes = [p.lower() for p in (rquery.group(3) if rquery.group(3) is not None else '').strip('|').split('|')]
munged_word = process_pipes(word, pipes)
story = story.replace(query, munged_word, 1)
if rquery.group(2) is not None: #if there is a '#' part we replace all instances
print "Looking for {{" + rquery.group(1) + rquery.group(2) + ".*?}}"
others = re.findall(r'{{' + rquery.group(1) + rquery.group(2) + '.*?}}', story)
if len(others) > 0:
story = replace_word(story, others[0], word) #iteratively replace the next instance
return story
# Modify user input based on certain modifying pipes
def process_pipes(word, pipes):
for pipe in pipes:
try:
word = {
'upper': lambda word: word.upper(),
'lower': lambda word: word.lower(),
'title': lambda word: word.title(),
'numeric': lambda word: p.number_to_words(word),
'ordinal': lambda word: p.ordinal(word),
collections.defaultdict: lambda word: word
}[pipe](word)
except Exception:
pass # just keep going if an error occurs processing a pipe
return word
# A helper function that will split the story up into chat-printable lengths
def yield_lines(line, max_size):
Binary file not shown.
+21 -12
View File
@@ -59,7 +59,7 @@ def resetGlobals(channel=""):
story[channel] = ""
nextword[channel] = {}
def get_stories(channel):
def get_stories(channel, botnick):
global state
global stories
state[channel] = State.thinking
@@ -73,11 +73,11 @@ def get_stories(channel):
for idx, story in enumerate(stories[channel]):
sendmsg(channel, "[{}] {} ({} words)".format(idx, story[0], story[2]))
time.sleep(0.5 * THROTTLE_FACTOR)
sendmsg(channel, "Please select a story by index:")
sendmsg(channel, "Please select a story by index by saying '{}: <number>':".format(botnick))
state[channel] = State.story_selection
# Handle user input when the bot is directly addressed
def handle_bot_msg(channel, msg):
def handle_bot_msg(channel, msg, botnick):
global state
global stories
@@ -92,9 +92,9 @@ def handle_bot_msg(channel, msg):
if saved_state != State.idle and msg == "!quit":
quit_game(channel)
elif saved_state == State.idle and msg == "startgame":
get_stories(channel)
get_stories(channel, botnick)
elif saved_state == State.story_selection:
handle_story_selection(channel, msg)
handle_story_selection(channel, msg, botnick)
elif saved_state == State.word_input:
handle_story_step(channel, msg)
else:
@@ -106,7 +106,7 @@ def quit_game(channel):
sendmsg(channel, "Ok, quitting the current game.")
# Handle user input when we are in story selection mode
def handle_story_selection(channel, msg):
def handle_story_selection(channel, msg, botnick):
global stories
global state
try:
@@ -120,19 +120,19 @@ def handle_story_selection(channel, msg):
with open(stories[channel][imsg][1], "r") as storyFile:
story[channel] = storyFile.read()
stories[channel] = {} # Clear out the saved selectable stories in memory
story_start(channel)
story_start(channel, botnick)
except ValueError:
sendmsg(channel, "Invalid selection. Try again!")
state[channel] = State.story_selection
# Handle when a story is being started
def story_start(channel):
def story_start(channel, botnick):
global story
global state
global nextword
state[channel] = State.thinking
sendmsg(channel, "Alright! Let's get started!")
sendmsg(channel, "Alright! Let's get started! Say '{}: <word>' to give me words.".format(botnick))
nextword[channel] = madlib.find_next_word(story[channel], True)
time.sleep(0.5 * THROTTLE_FACTOR)
sendmsg(channel, "Give me {}:".format(nextword[channel][1]))
@@ -169,7 +169,7 @@ def finish_story(channel):
sendmsg(channel, '=' * MAX_LINE)
for line in story[channel].splitlines():
for part in madlib.yield_lines(line, MAX_LINE):
time.sleep(0.4 * THROTTLE_FACTOR)
time.sleep(0.6 * THROTTLE_FACTOR)
sendmsg(channel, part)
padlen = (MAX_LINE - 9)/2
mod = (MAX_LINE - 9) % 2
@@ -186,10 +186,19 @@ def sendmsg(chan , msg):
ircsock.send("PRIVMSG {} :{}\n".format(chan, msg))
def joinchan(chan):
global state
state[chan] = State.idle
ircsock.send("JOIN {}\n".format(chan))
def rollcall(channel, botnick):
sendmsg(channel, "Do you like MadLibs? Start a collaborative story by saying '{}: startgame'".format(botnick))
global state
if channel not in state:
state[channel] = State.idle
if state[channel] == State.idle:
sendmsg(channel, "Do you like MadLibs? Start a collaborative story by saying '{}: startgame'".format(botnick))
else:
sendmsg(channel, "A game is already in progress. Say '{}: <word>' to provide me with the next word or '{}: !quit' to stop the current game".format(botnick, botnick))
def connect(server, channel, botnick):
ircsock.connect((server, 6667))
@@ -222,7 +231,7 @@ def listen(botnick):
rollcall(channel, botnick)
elif message.startswith(botnick) == True:
botmsg = botmsgre.match(message).group(1)
handle_bot_msg(channel, botmsg)
handle_bot_msg(channel, botmsg, botnick)
sys.stdout.flush()
time.sleep(1 * THROTTLE_FACTOR)
+1 -1
View File
@@ -11,7 +11,7 @@ fuzz_amount = 3
def make_puzzle(obfuscate=True):
answer = 0
bonus = 0
puzzle = random.choice(["Prove you're not a robot: ", "Are you a robot?: ", "Anti-bot check: ", "Counter-cndorphant measures: ", "Cosnok countermeasures: ", "Anti-tildethief precautions: "])
puzzle = random.choice(["Prove you're not a robot: ", "Are you a robot?: ", "Anti-bot check: ", "Counter-cnd0rphant measures: ", "Cosn0k countermeasures: ", "Anti-tilde7hief precautions: "])
puzzle += random.choice(["What is", "How many is", "What do you get from", "What do you get with", "What is the value of", "Can you answer", "Can you tell me"])
puzzle += " "
roll = random.randrange(0,18)
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash
if [[ ! `pidof -sx madlibbot.py` ]]; then
nohup ./madlibbot/madlibbot.py -s 127.0.0.1 -n madlibbot -c \#madlibs >> madliblog 2>> madliblog &
nohup ./madlibbot/madlibbot.py -s 127.0.0.1 -n madlibbot -c \#bots >> madliblog 2>> madliblog &
echo "Starting madlibbot"
else
echo "madlibbot has already been started"
+51 -33
View File
@@ -1,13 +1,13 @@
krowbar&^%2211&^%1528995967
krowbar&^%2354&^%1537371836
karlen&^%498&^%1527613440
endorphant&^%682&^%1444775660
jumblesale&^%24&^%1426171214
marcus&^%2571&^%1528142058
marcus&^%2574&^%1530026564
papa&^%181&^%1474509971
epicmorphism&^%5&^%1421937744
audy&^%83&^%1504564254
kc&^%28&^%1480730333
vilmibm&^%15&^%1520970953
vilmibm&^%17&^%1535654280
cmr&^%2244&^%1485978592
imt&^%519&^%1424087616
cndorphant&^%788&^%1424094192
@@ -39,27 +39,27 @@ synergian&^%22&^%1458152889
dheeraj&^%5&^%1456489270
demobot&^%6&^%1454439605
premysl&^%65&^%1461768606
minerobbe&^%268&^%1529052078
xkeeper&^%14&^%1461967961
minerobbe&^%269&^%1530328006
xkeeper&^%199&^%1536855625
cosnok&^%807&^%1508878859
escobar&^%1&^%1475431401
amicabot&^%30&^%1481225205
caff&^%1022&^%1528745010
kadin&^%5&^%1479870008
desvox&^%5&^%1481632697
caff&^%1023&^%1532662853
kadin&^%8&^%1537306549
desvox&^%25&^%1537178981
mankins&^%3&^%1480211581
cinch&^%2&^%1480454755
caffbot&^%968&^%1528745018
caffbot&^%969&^%1532662872
evilbot&^%4&^%1480693919
tybaltcat&^%7&^%1481076625
minerbot&^%146&^%1520382015
mio&^%339&^%1506434277
archangel&^%464&^%1524447604
tehfraga&^%263&^%1527511198
mio&^%347&^%1529720473
archangel&^%476&^%1537304671
tehfraga&^%537&^%1537326808
sushi&^%10&^%1493253212
troido&^%285&^%1529052063
gamebot&^%160&^%1529052049
nilaky&^%1152&^%1529028413
troido&^%287&^%1533042798
gamebot&^%178&^%1533042867
nilaky&^%1339&^%1537312079
bucket&^%103&^%1507931139
lolbot&^%1&^%1502568407
m455&^%12&^%1512076715
@@ -72,32 +72,32 @@ pinhook&^%8&^%1509744722
emfor&^%3&^%1509671353
k2l8m11n2&^%11&^%1510932395
sacredpix&^%3&^%1522082931
deltawitc&^%2018&^%1529022699
login&^%1147&^%1529054074
deltawitc&^%3045&^%1537372902
login&^%2076&^%1537359686
kelpiebot&^%3&^%1513101957
unreal&^%1&^%1514940020
tildethie&^%3000&^%1521573658
unreal&^%2&^%1534387108
tildethie&^%5040&^%1537374440
kinsey&^%26&^%1520446672
testgameb&^%2&^%1517405361
erin&^%2&^%1517681999
wuz&^%3&^%1518125300
hashdang&^%4&^%1518666906
ubergeek&^%63&^%1526043601
ubergeek&^%63&^%1530410162
silver&^%9&^%1519333029
equa&^%47&^%1528124305
equa&^%53&^%1534373756
audiodude&^%2&^%1519453927
jumblesal&^%1&^%1519746512
whimsy&^%45&^%1527777458
wangofett&^%100&^%1528482540
whimsy&^%47&^%1529678733
wangofett&^%179&^%1537310239
saturn597&^%3&^%1521429369
cwmccabe&^%2&^%1521598124
lucidiot&^%28&^%1526201925
tracer&^%1&^%1521744878
jan6&^%571&^%1529054825
jan6&^%1052&^%1536870225
jan&^%10&^%1522319160
etathetae&^%3&^%1522937843
eeeeeta&^%31&^%1527704747
cmccabe&^%66&^%1528506935
eeeeeta&^%51&^%1535563434
cmccabe&^%79&^%1529698164
jan6_test&^%7&^%1523252589
jan6_&^%8&^%1523641589
carbon&^%9&^%1524135505
@@ -105,13 +105,31 @@ ne1&^%7&^%1524024485
Halian&^%32&^%1528360263
lunasspec&^%4&^%1524164784
bowlercap&^%3&^%1524165068
littlebig&^%36&^%1529000570
severak&^%6&^%1528901245
littlebig&^%46&^%1535927253
severak&^%16&^%1533802439
ralph&^%4&^%1526980620
benjaminw&^%80&^%1529074458
von&^%120&^%1529074049
ensis&^%164&^%1529072988
benjaminw&^%503&^%1537371492
von&^%392&^%1537371528
ensis&^%1507&^%1537370624
simon&^%26&^%1527937489
benharri&^%62&^%1529075403
benharri&^%1397&^%1536689051
cpb&^%3&^%1528930564
calmbit&^%4&^%1529073811
calmbit&^%146&^%1537237248
wisebot&^%4466&^%1537376483
paannd_a&^%2&^%1529617165
nincollin&^%6&^%1531186900
x4464&^%1&^%1532028546
pounce&^%19&^%1532133325
von_&^%5&^%1532502104
livix&^%7&^%1533603142
ben&^%3&^%1533767627
npa&^%78&^%1536235183
ezo&^%6&^%1533883842
aliasless&^%30&^%1537198276
kirch&^%41&^%1535571833
root&^%2&^%1535558514
byte&^%5&^%1536416308
qbe&^%6&^%1537112151
informati&^%3&^%1536733938
h00fi&^%1&^%1537050053
fantoro&^%4&^%1537106482
+5
View File
@@ -40,3 +40,8 @@
1522267660&^%jan&^%What is the last film you saw?
1522846620&^%krowbar&^%Have you ever had to wear a uniform to school?
1523121085&^%jan6&^%no topics in the tropic
1534250166&^%krowbar&^%hello world
1534294757&^%deltawitc&^%All hail DeltaWitch the Bot Queen
1534300117&^%unreal&^%All hail DeltaWitch the Bot Queen and Unreal the Bot Monarch
1534300975&^%unreal&^%All hail DeltaWitch the Bot Queen and Unreal, Sovran of Bots
1534301504&^%deltawitc&^%All hail DeltaWitch the Bot Queen, and Unreal, Sovran of Bots
+6
View File
@@ -250,3 +250,9 @@
1526577609&^%archangel&^%When you were in grade school, what did you want to be when you grew up? Why?
1526842324&^%vilmibm&^%welcome, wave of new users <3
1528317036&^%vilmibm&^%what are the feels?
1529602271&^%vilmibm&^%welcome to the town! we're glad you're here. | some other channels that you can /join: #projects (discuss cool stuff other townies have made), #bots (experiment or play with bots), #dumpsterfire (talk about heavy shit)
1533541086&^%vilmibm&^%<3
1533794911&^%vilmibm&^%if you'd like to be included in the package of memories we're sending to abraxas's family, please get your posts into the BBJ thread by 2018-08-09 19:00 UTC. <3
1534119128&^%vilmibm&^%<3 | for more about this chat, see https://tilde.town/wiki/irc.html or run `wiki get irc`
1534311634&^%vilmibm&^%welcome! to learn more about this chat, check out https://tilde.town/wiki/irc.html or run `wiki get irc`
1535572794&^%vilmibm&^%weechat has been updated! quit and run `chat` to get the new version if you want | to learn more about this chat, check out https://tilde.town/wiki/irc.html or run `wiki get irc`
+1 -4
View File
@@ -1,4 +1 @@
krowbar&^%6&^%2
jan&^%0&^%1vilmibm&^%0&^%1etathetae&^%1&^%0
etathetae&^%0&^%2
jan6&^%0&^%1vilmibm&^%0&^%1vilmibm&^%0&^%1vilmibm&^%0&^%1vilmibm&^%0&^%1vilmibm&^%0&^%1vilmibm&^%0&^%1archangel&^%0&^%1vilmibm&^%0&^%1vilmibm&^%0&^%1
vilmibm&^%0&^%2