From bf6e413eb6ef44d14a07dc412e916fb77da5db8a Mon Sep 17 00:00:00 2001 From: osmarks Date: Sun, 1 Nov 2020 17:32:02 +0000 Subject: [PATCH] further achievements --- assets/achievements/error.png | Bin 0 -> 748 bytes assets/achievements/rtfm.png | Bin 0 -> 755 bytes src/achievement.py | 9 ++++++--- src/main.py | 3 ++- src/util.py | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 assets/achievements/error.png create mode 100644 assets/achievements/rtfm.png diff --git a/assets/achievements/error.png b/assets/achievements/error.png new file mode 100644 index 0000000000000000000000000000000000000000..cdd92c4b0ca4d951de6bc02ff4414bc6f1fbc9d8 GIT binary patch literal 748 zcmV zv2GhN42G$qL)UKgRFCm9^eMV_E6~R((5-8hyh7$?bH>YbU4pLNRQMPR5=oId9k2EQ z@nVVk@8>6qIXef3yZ8*-dA$XIZ~IT10RBGQpKx7XU%z~A@%i!dwnbLcRB^}Q$gkP$ z4?Nfi$}jAQ2)GCuLg02WMgS0@xp<8T#Z_1VAcPQO9EYPqoF6wSe7@AT8H$TciWd^+ z0tG@@${pIrZ*u849K{~UHMk$Kvx#htsZia%G~xz$&u|&nC;&xu6`j7sAy7}^WGZU( zL=Lzj1j#xMM@6PA5g)f^KwmuBJbgYUx$`N?%*JrWP0$Ku&ZNll&7`pdZk|5*?)C=} zg@|ji`fBYeuQ4?mI&| z9g(>4e7$PPeTv@AmoHA1!=y27hO}^ zx_RySKQ%+*URaB@s_Vr^wzo=kMOHCLXw0cI?)dbmU@1!`C<;7rm(!TgZn%xCjj|fI z1FqfxJn<4@2V4$hM!JbFg9`wC#7pnHMb_yF+DmE4Bet|e;^sk=g4L><_@@6r%A_x| zVymKp1sCBO`H(p0X6X$FrtilUGKB!-tO+YwooECfMwtSgxLOX0DdiIfnp=56CvIuN zW+Jf|WS8oJ9$dQ^qz80_Y1Q_eWV3N?-x_Nze%_4j3@{t_Y+iZSnPLQ8P;pJ+dALRa zIEvV>Tz1AW{QawYPJFtfA*)E7WHSfzs@rN#5D}dOD_(kmmwsm`lA1uKps*7r>r_`r zl|j)%B|- ecM9A3+1o#rQtuMYd3?_R0000OLSxH8G4#0bz#ZC))TOGVChonU4kogW@Ke!;tZ|8l4T{vu@gVad+Okq zKlU#lUlOWzvHLy4e4b|jcwfHF0{Hv*^E3-kf}9!d#SE_JbUfhrm*uN#V#r`0?#Fty z-EOh)zi_vkVS9Z5fVe~S)04F0VqO&cbUfgXUaY^@VTON~|J_J1ym!ks!r$_XDVmIzMj)XM~1I2nk7SD!x7huH|jXRE`ow(GyJXNanR@_V# zdPT8a&^VV{1zRkJaUWzN*?4_u4Q)ZWfHIF8w@g7T+}6|>8<=ppai?QSDOJ5|!XEqw|qv>}9RvmNj^bos7@wi7V>1rM4`i zLE0{LIa7JP@!qyIi?cL!72{?!_-fx|ZPGTXo3Ww{c4FgwE2`@|$V5=ei@#i0G_HR0 zqMTWvnIRimzFNq#Sv}Hfx0+&H{w)lNb=5QCW@$CttOmZ`lJi!(n53t%%M3k*+vfVV znqGrjVj{g|T-~@OGzTqv16u;ja5q->R&(jZml5R+*$j59jEP<;pj3F`_MBq!CG0gW z0ab%eRvEWiRUDvv+`}+*US?D=V5?CsJ?NJFX*9q{{V=8@TQzu2B!c3002ovPDHLkV1jP9Wk3J` literal 0 HcmV?d00001 diff --git a/src/achievement.py b/src/achievement.py index 5691120..fc72326 100644 --- a/src/achievement.py +++ b/src/achievement.py @@ -15,7 +15,9 @@ achievements = { "spectre_of_communism": Achievement("Containment Efforts Ongoing", "Refer to the 'spectre of communism' in a message.", "A spectre is haunting Europe. The spectre of communism. Containment efforts are ongoing and full containment is projected by 2036."), "test": Achievement("Test", "Test achievement. Obtained for testing.", "Congratulations, you ran the test command!"), "spam": Achievement("beesbeesbeesbeesbeesbeesbeesbeesbees", "Send a long message containing the same thing repeatedly.", "You should probably not do this, nobody* likes spam!"), - "unicode_abuse": Achievement("Anomalous Unicode", "Send a high proportion of weird Unicode characters in a message.", "h̵͖̻̮̗̹̆͛͆̎ͮͤͫ͛ͦ̓̅ͤ́͢é͒ͧ̌̀ͪ̈͂̈́̉ͣ̅̿̄̌̋̿̽̚͏̛͏͚̯͉̟͇̼̹͎ͅa̠̹̘͎̫̜̞̩͖̟̟͍͇͈͍̝͕͛ͥ͊̾̈́ͩͯͩͭ̆̋͐͗̉͋̓̀͝v͎͖̜͎͔̞͚͉̺̞̘̥͖̝͚̺̍ͤ̌͂ͨ̃̅ͫ̿͛ͯ̓̉̆̎͊̀̚̕͟s̪̠̟̣̝̹̭̻̈́ͤ͗̏ͮ̂ͯ̈́̊ͩ̓̆̌̆͌̽̓̈́̚͢͞e̛̞̙̜̗̰͕͕͎̺͍̭̲̟̭̲̫̬͓ͯ̅̓̆̂̔̃͟r̷̛̮̮͇̳̳̾ͯͮͩ̏͂ͤ̿̽ͧ͒͋́̕ͅͅv̴̠͉̼̮̭̘ͪͯͦ͌́ͯ̒̃̀́̃͜͝ͅe̵̷̢͕̣̻̥̲͓̼͍̱͕̮̯̱̤̹̱̝̎̓̈́̿ͤ̔̍ͭͭ͐ͅŗ̔ͮͯ͂́͏̻͈̱ͅ ̣͇̼͊̄ͫ̆̍̄̀̀̓͊͐͋̌͘͠į̱͔̰̭̫̱̫̊ͪ̅ͥ̈́ͥ̐͌̅ͪ̅ͨ̎̀͘͝s̍͑̌̋̅͌͂ͨͬͯ̇͊҉̛̱̺͕̰͓̗̖̬͡͡ ̥̤̺̖̪̪́ͯͣ̏̅̈ͣ̿̀͠͠͞i̢̛̭̰̻͈̦̣̮̞̤̩̊̌̾͛ͭͦ̆ͮ̃̎ͪ̔ͬ͊̆͂ͫͅn̸̖͚̣̪̩̏ͥ̈́̅ͯ̔͆́ͦ͗͛͒̃̃ͫ͟͜͝͠ȩ̸͎̟̣̞͉̫̗̙̻̯͍̰̣̌ͪͨ͛̆̕͡v̙͙̲͕͔̦̣̺͔̖͉̜̲̩̈̿ͥ̎͊̈́̊ͯͯ͒ͭ̊̀͢i̪͈̣̱̞̥̰̟̣̩̼̻̪̳̤͇̻̹͉͗ͭ͆̆̎̀͑͑̆͋̏̏͊ͣͦ͆ͣ̈́̓͟͢ţ̵̘̫̯͓̻̗͕̘͙̯̞̪̪̲̤̬̜͕ͫ̄̌̓̎͌ͧ̔͟͢ͅa̸̧̭̲̯̳̔́͋̐͂̇ͪ̔̐́̚͢b͐̅̔ͭ͗̊̂̾̀̓ͭͭ͑ͤ̏̐̃ͩͬ҉̞̼̮̤̝̲̳͓̗̤̫̭̝̹̙͘͟͝ļ̷͈̭̖͓̜̬͔̻͔̀̎ͯ͗̐̽̏ͦ̊͗ͧ́͘ͅe̢͍̦̗̬̝̠͔̳̣̯̮̣̹͍͙̞̜ͣ̉͆̊̀̎ͦ͌̂̋̊ͨ͛́") + "unicode_abuse": Achievement("Anomalous Unicode", "Send a high proportion of weird Unicode characters in a message.", "h̵͖̻̮̗̹̆͛͆̎ͮͤͫ͛ͦ̓̅ͤ́͢é͒ͧ̌̀ͪ̈͂̈́̉ͣ̅̿̄̌̋̿̽̚͏̛͏͚̯͉̟͇̼̹͎ͅa̠̹̘͎̫̜̞̩͖̟̟͍͇͈͍̝͕͛ͥ͊̾̈́ͩͯͩͭ̆̋͐͗̉͋̓̀͝v͎͖̜͎͔̞͚͉̺̞̘̥͖̝͚̺̍ͤ̌͂ͨ̃̅ͫ̿͛ͯ̓̉̆̎͊̀̚̕͟s̪̠̟̣̝̹̭̻̈́ͤ͗̏ͮ̂ͯ̈́̊ͩ̓̆̌̆͌̽̓̈́̚͢͞e̛̞̙̜̗̰͕͕͎̺͍̭̲̟̭̲̫̬͓ͯ̅̓̆̂̔̃͟r̷̛̮̮͇̳̳̾ͯͮͩ̏͂ͤ̿̽ͧ͒͋́̕ͅͅv̴̠͉̼̮̭̘ͪͯͦ͌́ͯ̒̃̀́̃͜͝ͅe̵̷̢͕̣̻̥̲͓̼͍̱͕̮̯̱̤̹̱̝̎̓̈́̿ͤ̔̍ͭͭ͐ͅŗ̔ͮͯ͂́͏̻͈̱ͅ ̣͇̼͊̄ͫ̆̍̄̀̀̓͊͐͋̌͘͠į̱͔̰̭̫̱̫̊ͪ̅ͥ̈́ͥ̐͌̅ͪ̅ͨ̎̀͘͝s̍͑̌̋̅͌͂ͨͬͯ̇͊҉̛̱̺͕̰͓̗̖̬͡͡ ̥̤̺̖̪̪́ͯͣ̏̅̈ͣ̿̀͠͠͞i̢̛̭̰̻͈̦̣̮̞̤̩̊̌̾͛ͭͦ̆ͮ̃̎ͪ̔ͬ͊̆͂ͫͅn̸̖͚̣̪̩̏ͥ̈́̅ͯ̔͆́ͦ͗͛͒̃̃ͫ͟͜͝͠ȩ̸͎̟̣̞͉̫̗̙̻̯͍̰̣̌ͪͨ͛̆̕͡v̙͙̲͕͔̦̣̺͔̖͉̜̲̩̈̿ͥ̎͊̈́̊ͯͯ͒ͭ̊̀͢i̪͈̣̱̞̥̰̟̣̩̼̻̪̳̤͇̻̹͉͗ͭ͆̆̎̀͑͑̆͋̏̏͊ͣͦ͆ͣ̈́̓͟͢ţ̵̘̫̯͓̻̗͕̘͙̯̞̪̪̲̤̬̜͕ͫ̄̌̓̎͌ͧ̔͟͢ͅa̸̧̭̲̯̳̔́͋̐͂̇ͪ̔̐́̚͢b͐̅̔ͭ͗̊̂̾̀̓ͭͭ͑ͤ̏̐̃ͩͬ҉̞̼̮̤̝̲̳͓̗̤̫̭̝̹̙͘͟͝ļ̷͈̭̖͓̜̬͔̻͔̀̎ͯ͗̐̽̏ͦ̊͗ͧ́͘ͅe̢͍̦̗̬̝̠͔̳̣̯̮̣̹͍͙̞̜ͣ̉͆̊̀̎ͦ͌̂̋̊ͨ͛́"), + "rtfm": Achievement("RTFM", "Tell someone to read the documentation.", "Apparently, people won't do this without prompting half the time."), + "error": Achievement("You broke it", "Cause an internal error in the bot", "I should probably fix this.") } async def achieve(bot: commands.Bot, message: discord.Message, achievement): @@ -63,6 +65,7 @@ def setup(bot): async def message_listener(msg: discord.Message): content = msg.content content_len = len(msg.content) - if re.match("spect(re|er).{,20}(communism|☭)", content): await achieve(bot, msg, "spectre_of_communism") + if re.match("spect(re|er).{,20}(communism|☭)", content, re.IGNORECASE): await achieve(bot, msg, "spectre_of_communism") if re.match(r"^(.+)\1+$", content) and len(content) >= 1950: await achieve(bot, msg, "spam") - if content_len > 30 and (len(re.findall("[\u0300-\u036f\U00040000-\U0010FFFF]", content)) / content_len) > 0.35: await achieve(bot, msg, "unicode_abuse") \ No newline at end of file + if content_len > 30 and (len(re.findall("[\u0300-\u036f\U00040000-\U0010FFFF]", content)) / content_len) > 0.35: await achieve(bot, msg, "unicode_abuse") + if re.match("(RTFM|(read|look|view|use).{,20}(doc|man|instruction))", content, re.IGNORECASE): await achieve(bot, msg, "rtfm") \ No newline at end of file diff --git a/src/main.py b/src/main.py index 4a15871..2326e0d 100644 --- a/src/main.py +++ b/src/main.py @@ -16,6 +16,7 @@ import rolldice import tio import db import util +import achievement config = util.config @@ -47,9 +48,9 @@ async def on_command_error(ctx, err): if isinstance(err, commands.MissingRequiredArgument): return await ctx.send(embed=util.error_embed(str(err))) try: trace = re.sub("\n\n+", "\n", "\n".join(traceback.format_exception(err, err, err.__traceback__))) - #print(trace) logging.error("command error occured (in %s)", ctx.invoked_with, exc_info=err) await ctx.send(embed=util.error_embed(util.gen_codeblock(trace), title="Internal error")) + await achievement.achieve(ctx.bot, ctx.message, "error") except Exception as e: print("meta-error:", e) @bot.command(help="Gives you a random fortune as generated by `fortune`.") diff --git a/src/util.py b/src/util.py index d9532a3..4affd65 100644 --- a/src/util.py +++ b/src/util.py @@ -10,6 +10,7 @@ import discord import toml import os.path from discord.ext import commands +import hashlib config = toml.load(open("config.toml", "r")) @@ -245,4 +246,4 @@ async def get_asset(bot: commands.Bot, identifier): return url def hashbow(thing): - return hash(thing) % 0x1000000 \ No newline at end of file + return int.from_bytes(hashlib.blake2b(thing.encode("utf-8")).digest()[:3], "little") \ No newline at end of file