diff --git a/Bot.py b/Bot.py index 06936a8..01ec4cd 100644 --- a/Bot.py +++ b/Bot.py @@ -1,6 +1,6 @@ # Beardless Bot # Author: Lev Bernstein -# Version: 8.7.0 +# Version: 8.7.1 # Default modules: import asyncio @@ -19,6 +19,7 @@ # Other: import eggTweetGenerator +from dice import * from facts import * game = False @@ -144,7 +145,7 @@ async def on_ready(): await client.user.edit(avatar=pic) print("Avatar live!") except discord.HTTPException: - print("Avatar failed to update!") + print("Avatar failed to update! You might be sending requests too quickly.") except FileNotFoundError: print("Avatar file not found! Check your directory structure.") @@ -184,7 +185,7 @@ async def on_message(text): if allBet == False and bet < 0: # Check if !allBet first to avoid attempting to cast "all" to int report = "Invalid bet. Choose a value greater than or equal to 0." else: - with open('resources/money.csv', 'r') as csvfile: + with open('resources/money.csv', 'r') as csvfile: # In future, maybe switch to some kind of NoSQL db like Mongo instead of storing in a csv reader = csv.reader(csvfile, delimiter=',') for row in reader: if str(text.author.id) == row[0]: @@ -457,9 +458,8 @@ async def on_message(text): try: newtarg = await text.guild.fetch_member(str(target)) report = newtarg.avatar_url - except discord.NotFound as err: - report = "Error code 10007: Discord Member not found!" - print(err) + except discord.NotFound: + report = "Discord Member " + str(target) + " not found!" await text.channel.send(report) if text.content.startswith('-mute') or text.content.startswith('!mute'): @@ -528,12 +528,12 @@ async def on_message(text): await text.channel.send(report) return - if text.content.startswith('!song') or text.content.startswith('!playlist'): + if text.content.startswith('!song') or text.content.startswith('!playlist') or text.content.startswith('!music'): linker = ' Here\'s my playlist (discord will only show the first hundred songs): https://open.spotify.com/playlist/2JSGLsBJ6kVbGY1B7LP4Zi?si=Zku_xewGTiuVkneXTLCqeg' await text.channel.send(linker) return - if text.content.startswith('!leaderboard') or text.content.startswith('!lb'): # This is incredibly memory inefficient. It's not a concern now, but if resources/money.csv becomes sufficiently large, this code will require a rewrite. + if text.content.startswith('!leaderboard') or text.content.startswith('!lb'): storedVals = [] storedNames = [] finalList = [] @@ -545,7 +545,7 @@ async def on_message(text): reader = csv.reader(csvfile, delimiter=',') for row in reader: bank = int(row[1]) - if bank != 0: # Don't bother displaying in the leaderboard people with 0 BeardlessBucks + if bank != 0: # Don't bother displaying info for people with 0 BeardlessBucks storedVals.append(bank) name = row[2] storedNames.append(name) @@ -554,7 +554,7 @@ async def on_message(text): for x,y in diction.items(): diction2[x[:-5]] = y sortedDict = OrderedDict(sorted(diction2.items(), key = itemgetter(1))) - print(sortedDict) + #print(sortedDict) limit = 10 if len(sortedDict) < 10: limit = len(names) @@ -563,71 +563,18 @@ async def on_message(text): if len(sortedDict) > 10: sortedDict.pop(x) break - print(sortedDict) + #print(sortedDict) for x, y in sortedDict.items(): names.append(x) - for i in range(len(names)): - print(names[i]) + #for i in range(len(names)): + #print(names[i]) for i in range(limit): emb.add_field(name= (str(i+1) + ". " + names[(limit-1)-i]), value= str(sortedDict[names[(limit-1)-i]]), inline=True) await text.channel.send(embed=emb) return if text.content.startswith('!d') and ((text.content.split('!d',1)[1])[0]).isnumeric() and len(text.content) < 12: # The isnumeric check ensures that you can't activate this command by typing !deal or !debase or anything else. - report = "Invalid side number. Enter 4, 6, 8, 10, 12, 20, or 100, as well as modifiers. No spaces allowed. Ex: !d4+3" - command = text.content.split('!d',1)[1] - print(command[0]) - print(command) - isTen = False # Because !d10 and !d100 share their first two characters after the split, I was getting errors whenever I ran !d10 without a modifier. - # This boolean takes care of those errors. The problem arises because both the conditions for rolling a d10 and 2/3 of the conditions for rolling a d100 - # would be met whenever the bot tried to roll a d10; then, when checking if command[2]=="0", I would get an array index out of bounds error, as the - # length of the command is actually only 2, not 3. However, with the boolean isTen earlier in the line, now it will never check to see if command has that - # third slot. - if "-" in command: - modifier = -1 - else: - modifier = 1 - if text.content == '!d2' or text.content == '!d1': - report = "Invalid side number. Enter 4, 6, 8, 10, 12, 20, or 100, as well as modifiers. No spaces allowed. Ex: !d4+3" - else: - if command[0] == "4": - if len(command)==1: - report = randint(1,4) - elif (command[1]=="+" or command[1] == "-"): - report = randint(1,4) + modifier*int(command[2:]) - if command[0] == "6": - if len(command)==1: - report = randint(1,6) - elif (command[1]=="+" or command[1] == "-"): - report = randint(1,6) + modifier*int(command[2:]) - if command[0] == "8": - if len(command)==1: - report = randint(1,8) - elif (command[1]=="+" or command[1] == "-"): - report = randint(1,8) + modifier*int(command[2:]) - if command[0] == "1" and command[1] == "0": - if len(command)==2: - isTen = True - report = randint(1,10) - elif (command[2]=="+" or command[2] == "-"): - isTen = True - report = randint(1,10) + modifier*int(command[3:]) - if command[0] == "1" and command[1] == "2": - if len(command)==2: - report = randint(1,12) - elif (command[2]=="+" or command[2] == "-"): - report = randint(1,12) + modifier*int(command[3:]) - if command[0] == "2" and command[1] == "0": - if len(command)==2: - report = randint(1,20) - elif (command[2]=="+" or command[2] == "-") : - report = randint(1,20) + modifier*int(command[3:]) - if isTen == False and command[0] == "1" and command[1] == "0" and command[2] == "0": - if len(command)==3: - report = randint(1,100) - elif (command[3]=="+" or command[3] == "-"): - report = randint(1,100) + modifier*int(command[4:]) - await text.channel.send(report) + await text.channel.send(roll(text.content)) return if text.content.startswith('!reset'): @@ -731,8 +678,8 @@ async def on_message(text): await text.channel.send(buckmessage) return - if text.content.startswith("!hello") or text.content == "!hi": - answers = ["How ya doin?", "Yo!", "What's cookin?", "Hello!", "Ahoy!", "Hi!", "What's up?","Hey!"] + if text.content.startswith("!hello") or text.content == "!hi" or ("hello" in text.content and ("beardless" in text.content or "bb" in text.content)): + answers = ["How ya doin?", "Yo!", "What's cookin?", "Hello!", "Ahoy!", "Hi!", "What's up?", "Hey!", "How's it goin?", "Greetings!"] await text.channel.send(choice(answers)) return diff --git a/dice.py b/dice.py new file mode 100644 index 0000000..08c64b3 --- /dev/null +++ b/dice.py @@ -0,0 +1,58 @@ +# Dice roller for Beardless Bot +from random import randint + +def roll(message): + report = "Invalid side number. Enter 4, 6, 8, 10, 12, 20, or 100, as well as modifiers. No spaces allowed. Ex: !d4+3" + command = message.split('!d',1)[1] + #print(command[0]) + #print(command) + isTen = False # Because !d10 and !d100 share their first two characters after the split, I was getting errors whenever I ran !d10 without a modifier. + # This boolean takes care of those errors. The problem arises because both the conditions for rolling a d10 and 2/3 of the conditions for rolling a d100 + # would be met whenever the bot tried to roll a d10; then, when checking if command[2]=="0", I would get an array index out of bounds error, as the + # length of the command is actually only 2, not 3. However, with the boolean isTen earlier in the line, now it will never check to see if command has that + # third slot. + if "-" in command: + modifier = -1 + else: + modifier = 1 + if message == '!d2' or message == '!d1': + report = "Invalid side number. Enter 4, 6, 8, 10, 12, 20, or 100, as well as modifiers. No spaces allowed. Ex: !d4+3" + else: + if command[0] == "4": + if len(command)==1: + report = randint(1,4) + elif (command[1]=="+" or command[1] == "-"): + report = randint(1,4) + modifier*int(command[2:]) + elif command[0] == "6": + if len(command)==1: + report = randint(1,6) + elif (command[1]=="+" or command[1] == "-"): + report = randint(1,6) + modifier*int(command[2:]) + elif command[0] == "8": + if len(command)==1: + report = randint(1,8) + elif (command[1]=="+" or command[1] == "-"): + report = randint(1,8) + modifier*int(command[2:]) + elif command[0] == "1" and command[1] == "0": + if len(command)==2: + isTen = True + report = randint(1,10) + elif (command[2]=="+" or command[2] == "-"): + isTen = True + report = randint(1,10) + modifier*int(command[3:]) + elif command[0] == "1" and command[1] == "2": + if len(command)==2: + report = randint(1,12) + elif (command[2]=="+" or command[2] == "-"): + report = randint(1,12) + modifier*int(command[3:]) + elif command[0] == "2" and command[1] == "0": + if len(command)==2: + report = randint(1,20) + elif (command[2]=="+" or command[2] == "-") : + report = randint(1,20) + modifier*int(command[3:]) + elif isTen == False and command[0] == "1" and command[1] == "0" and command[2] == "0": + if len(command)==3: + report = randint(1,100) + elif (command[3]=="+" or command[3] == "-"): + report = randint(1,100) + modifier*int(command[4:]) + return report diff --git a/eggTweetGenerator.py b/eggTweetGenerator.py index 22692d8..2a92659 100644 --- a/eggTweetGenerator.py +++ b/eggTweetGenerator.py @@ -1,8 +1,5 @@ -from random import choice -from random import random -from random import randint - #The following markov chain code was provided by CSTUY SHIP. +from random import choice, randint KEY_SIZE = 2 FILE = 'resources/eggtweets_clean.txt' diff --git a/facts.py b/facts.py index b8f1f88..81fba86 100644 --- a/facts.py +++ b/facts.py @@ -1,5 +1,6 @@ # Fun facts for Beardless Bot from random import choice + def fact(): facts = [ "The scientific term for brain freeze is sphenopalatine ganglioneuralgia.", diff --git a/resources/eggtweets_clean.txt b/resources/eggtweets_clean.txt index 97e4f82..6c47df5 100644 --- a/resources/eggtweets_clean.txt +++ b/resources/eggtweets_clean.txt @@ -905,7 +905,7 @@ this is so good this is so sick this is us this is what happens after i talk to remmy sorry -this is where your sub money goes +this is where your sub money goes. this is your last chance. after this there is no turning back. you take the blue pill: the story ends, you wake up back in mid plat and believe whatever you want to believe. you take the red pill: you stay in the forge and i show you how deep the elo hole goes THIS ISN'T DMS DEALS OFF THE TABLE NOW YOU'LL NEVER GET A SECOND CHANCE This picture perfectly embodies me at BCX, I'm not in there because I'm out of frame trading pins LMFAO @@ -931,13 +931,13 @@ top 5 brawlhalla legends that start with the letter b top 5 inspirations: 1) Taza. tried it again out of raw instinct, it's warm out think it's gonna rain later great job poo brain Fucking unbelievable imbecile, left the call immediately pulled my socks up to my knees in shame tries to chug Starbucks again -TRUE -trying to have a conversation with him is impossible +TRUE! +trying to have a conversation with him is impossible. tweet during the daytime twilight_grove.mp4 Two months of work, countless sleepless hours, seven hundred miles in the desert, forty nine missed calls, eighteen missed cousins, one hundred thousand frames of pure entertainment unadulterated insane cosmic power It's finally out. -u did this instead of calling me back +u did this instead of calling me back. u have diarrhea ubisoft brawlhalla is big news but when does jcrew esports enter the scene because using my subs' mom's credit cards to scavenge for slim xs shirts is starting to get unethical uh ohs @@ -946,7 +946,7 @@ unfortunately, i have just been diagnosed with doo doo brain. as it turns out, i uninstalled twitter from my phone, realized that i lost all my drafts... now you'll never know the shit that creed pulled... unlike guns, which are also #1 but bmg refuses to accommodate them because there's two of them so they're also #2 unrusting a tweensy bit -up my ass +up my ass! update video update: i still dont know whats happening but i might be able to record videos and tie my shoelaces very fun stream today! i get really paralyzed by anxiety sometimes but i have to remember that when i just jump in headfirst it's so great, the time zooms by when we get to have our dumbo talks and cursed convos, makes me happy @@ -960,10 +960,10 @@ wait shit i did too uhhh autocorrect wait what wake up mr. pug want to test stuff with reno but a bit limited by training room, wish i could record a save state and play it back to see. if i'm not mistaken, reno slight nsig on orb is unjumpable because of its hitbox, but it seems like it can be fastfalled, does anyone know? -WAS I NOT CLEAR WITHOUT HESITATION REPTILEFAN926 WITHOUT HESITATION -was really struggling in a game of 2v2, but then creed started shouting in my ear about how we should think about attacking the moon one battalion at a time because of how it sends microwaves down to earth to make the penguins grow bigger and i saw the light +WAS I NOT CLEAR WITHOUT HESITATION REPTILEFAN926 WITHOUT HESITATION! +was really struggling in a game of 2v2, but then creed started shouting in my ear about how we should think about attacking the moon one battalion at a time because of how it sends microwaves down to earth to make the penguins grow bigger and i saw the light. we are mere ants in your godly presence -we love you creed dw bout it. ofc by we im referring to the group funding your scented sticker addiction +we love you creed dw bout it. ofc by we im referring to the group funding your scented sticker addiction. We're live now. well it's not made for you then is it sparky oh my gosh went back to record all the spare footage i've been building up for the past 5 months and found this gem @@ -991,7 +991,7 @@ When Addy gets the 3-0 reset vs. when LDZ comes back with the reverse 0-3 when dobrein and diakou play noel when i'm old will i still think poop is funny..? 22 year olds pls can i have some input when remmy grief -WHEN SHE GOT A BOOTY THO +WHEN SHE GOT A BOOTY THO! when they will add indiana jones to btrawlhala? when will my father tell me he's proud of me ? when you get flooded with so many of them constantly all the time it's hard to keep up sorry @@ -1028,7 +1028,7 @@ wow cake is such a cool guy u should go give him a follow wow the new menu screenshot feature is amazing, i had it written in a script for a video for things i'd like to see in the future but y'all already put it in before i could even make the vid tysm wow they really just put drake and josh in brawlhalla... i thought it would never happen but i guess they actually saw all my email requests wow this tweet blew up haha follow my twitter -wow this was two years ago +wow this was two years ago. wowzers i can't believe no balance patch immediately after everyone gets back from winter vacation while also considering patches in other games have to be pre-approved by playstation, xbox, and nintendo ahead of time.. nono devs aren't people wowzers look how cool and comfortable this premiere esports commentator looks in his pink giraffe buddy hoodie sold exclusively writing is so good for keeping your mind healthy, today i wrote a story called the bees go up your nose and i feel like i absorbed a 4gb usb drive directly into my frontal lobe @@ -1071,7 +1071,7 @@ you're a unique person with a unique style, and the character is just an express you're leaned over on the toilet, elbows delicately balanced on your thighs. as always, you cannot sit with your own mind, opening up twitter to distract from the nothingness within. poop. you quickly rise, pants still at your ankles, and applaud. your life has been changed. you're lucky i'm even responding to you right now with all the campbell's emails i have to sort through you're really just copying me everywhere huh -YOU'RE TELLING ME OTHER PEOPLE CAN GET THE FREE THING THAT I GOT FOR FREE FOR FREE INCONCEIVABLE +YOU'RE TELLING ME OTHER PEOPLE CAN GET THE FREE THING THAT I GOT FOR FREE FOR FREE INCONCEIVABLE! you're too sweet you've followed me long enough to know to just click the heart and move on you've heard of don't pee january but has uncle jeremiah informed you of the upcoming super piss april yet.? @@ -1085,15 +1085,21 @@ late cuz i was watching dev strema live tho the things i do for chat i'm changing the game i got vaccnated today -just found out about fiber, ,, shits crazy +just found out about fiber, shits crazy. anyone else wear earbuds outside so when you start having an increasingly intense argument out loud with yourself people don't think you're crazy i hate it here stop calling me an npc please, i'm not an npc!! I DON’T HAVE AN “NPC WALK” I WALK VERY NORMALLY LIKE A NORMAL PERSON -yo i got this as #1 on my home page recommended thats sick poggor champion -i have rat brain so i see big number i click +yo i got this as #1 on my home page recommended thats sick poggor champion! +i have rat brain so i see big number i click. i have notifs off so i didn’t see this till now sorry, this is so cute thank you!! NICE!! -new vsauce video new bo burnham special announced only shit my pants once so far today is looking pretty good +new vsauce video new bo burnham special announced only shit my pants once so far today is looking pretty good! surprise new vidyo he had 5 kids named george foreman +what, another new video!? wowzers, can't wait to watch this one and comment this message about how much i enjoyed it!! +what, i don't have fur. +very happy to announce the first ever PSYCH SUNDAYS! this is something i've been working really hard on behind the scenes for the past 12 minutes now, so i hope you're excited. SUNDAY @ 2:00PM PST! DON'T BE LATE FOR CLASS! +first person to guess this week's topic gets a gifted sub! +hold on now +new ivddee! psych sundays will go up tmrw on youtube. diff --git a/resources/money.csv b/resources/money.csv index c0c5afb..6d40f23 100644 --- a/resources/money.csv +++ b/resources/money.csv @@ -14,15 +14,15 @@ 490211398698270741,800,CherryPancakes#5005 613547232746012716,600,Comrade Weng_Joe8789[lil luck]#1177 250632400193716224,69,gamer447#7721 -696168318448435210,69,scuffed cj#2767 +696168318448435210,69,Scuffed cj#2767 281856272494493706,200,Mattion#6969 412998189755400193,0,DAN#9919 714149971397705740,1200,corvet corvet beach#0024 295072759992680469,871,YNeos#4444 511679866261864448,200,Shewrpy = senpai#6134 196354892208537600,210,Captain No-Beard#7511 -696729737720234094,3129,sunbored#8776 -687535372800229378,0,liarcake#3987 +696729737720234094,400,sunbored#8776 +687535372800229378,200,liarcake#3987 653729591306879016,538,Phizzuk#6688 375673292083822604,1,ebolawarrior30#2530 516687036997173250,0,monkey#2149 @@ -55,7 +55,7 @@ 323298221252411392,0,Sinnamon#0192 493282240093093900,650,slappie#3446 437053407942148096,1200,faultystart#6888 -687786333997236260,4600,thedrich#2925 +687786333997236260,0,thedrich#2925 267441559379771394,0,YungBrownie#0033 368450258973360129,11600,guantanamo greg#8480 705501936207528048,600,gerbaba#0649 @@ -70,7 +70,7 @@ 532187796090388498,200,ZOO#3755 495996344415027211,300,Rhelic#4674 319294606086766592,0,Green#2222 -347443559667859456,0,Abdalla82#5947 +347443559667859456,12800,Abdalla82#5947 730899480559222794,0,Tausty96#2230 218465004821676032,200,Mx02#5715 231262248176189440,310,Airship#9832 @@ -127,7 +127,7 @@ 488435718629359617,190,Pako the Third#3771 384107762189336586,0,Aryan.#5112 717699798060367913,0,Fiches#0837 -338025583827091457,200,ThermalLance#6328 +338025583827091457,420,ThermalLance#6328 459346089951100939,0,vla_na_kvadrat#0610 688209360362799178,0,terx#9253 541378560884211718,0,Stitch#0404 @@ -215,7 +215,7 @@ 763106018912763904,0,IWJNCIEHCWIC#4124 359790050415869953,290,FlankRusher113#4232 579356154887536641,300,nigritonigito#2652 -397183557040209921,0,SsuperCJ#8362 +397183557040209921,200,SsuperCJ#8362 395404962143666176,300,Nope#1293 383500279431168002,0,SkyFall#6666 431858243669721101,300,JoJ#9842 @@ -244,7 +244,7 @@ 321281931503337472,300,Rodi#5184 245595739110113282,300,Levi.194#5523 642553921323270169,0,Katelyn#1389 -494896671944343553,0,ChickenBoneGolfClub#0255 +494896671944343553,200,Amr#0255 536808261471436801,200,RMFG#9937 407368766624890891,300,mrmichaelarends#5376 464736903120420874,0,Arno2#4588 @@ -277,16 +277,16 @@ 532203241967058944,300,Xionis#0722 714436382860509234,200,copyfoxM5#8105 422557539507634186,300,JaeG_07#5210 -822319166391451699,320,Victor_12#1745 +822319166391451699,0,Victor_12#1745 101394200490147840,300,eggsoup#3154 -267796106828578816,350,Diriector_Doc#9340 +267796106828578816,1200,Diriector_Doc#9340 644494987534401537,200,Dusk#1347 819614504627208202,300,icefex#6434 768631519169609770,200,krabszs#0091 757753589128101999,300,Young#2007 541616547253452850,600,Maya#2222 501781013156986911,200,big scary man#8125 -332276238552924180,400,uhphyshall jupyter#7644 +332276238552924180,0,uhphyshall jupyter#7644 732231816680964186,0,Doomstroke1#1373 348894204631449603,0,oRayZor#3319 808567047318405120,69,baltyboi#2396 @@ -309,10 +309,21 @@ 514508040678932510,0,Sanji#5458 576629630153261076,290,!🅷🆉 MalWer#7503 629836683671765013,300,SoHVanish#3823 -351406041659080707,200,Sniffiest66#5647 +351406041659080707,102400,Sniffiest66#5647 787268752751460373,600,Slovenec#5170 814988784558669862,0,Natkkuno#4731 763620668175941662,300,Deraj#1353 767871533505970236,310,Vorweeb#1291 -710349008257810452,500,NotThatSwift#6337 -579221354797334548,300,markimoo 2048#7055 \ No newline at end of file +710349008257810452,0,NotThatSwift#6337 +579221354797334548,300,markimoo 2048#7055 +705559318925148200,420,SilverMist#3300 +807502461770268682,300,free_i_see_ghostz#3464 +655211830154756134,0,trolling turtle#3685 +736081866389585971,200,1* away from z7 gohan#7743 +686397689474056220,200,AYO!#5526 +460749767308214272,1660,GamyIan#0396 +544674840250941485,0,Jah#5987 +711774311236632627,309,Froggo#7218 +737073439390695434,6000,D1zzy#0206 +630091147192041502,0,vaporr#5076 +761033749487943731,800,ZxM0NSTA26#2122 \ No newline at end of file