simple.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import random
  2. from rollbot import as_command, Message, RollbotFailure, Command, Attachment
  3. from rollbot.injection import (
  4. ChannelAdmin,
  5. OriginAdmin,
  6. Debugging,
  7. Args,
  8. SenderName,
  9. ArgList,
  10. Config,
  11. )
  12. @as_command
  13. def isadmin(channel: ChannelAdmin, origin: OriginAdmin):
  14. return f"Channel: {channel}, Origin: {origin}"
  15. @as_command
  16. def debug(message: Message, debugging: Debugging):
  17. return f"{message}\nLast Error: {debugging}"
  18. @as_command
  19. def echo(body: Args, name: SenderName):
  20. return f"'{body}' - {name}"
  21. @as_command
  22. def greet():
  23. return random.choice(("Hi!", "Hello!", "안녕하세요", "こんにちは", "你好", "👋"))
  24. @as_command
  25. def console(argstr: Args):
  26. opts = ["NEVER GIVE UP", "I believe in you!", "You're doing your best, it's okay!"]
  27. if len(argstr) > 0:
  28. opts.append("It'll be okay, {}! Keep trying!".format(argstr))
  29. return random.choice(opts)
  30. @as_command
  31. def choice(args: Args, arg_list: ArgList):
  32. for delim in ("|", ";", ","):
  33. if delim in args:
  34. opts = args.split(delim)
  35. break
  36. else:
  37. opts = arg_list
  38. chosen = random.choice(opts).strip()
  39. return f"Randomly chose {chosen} from {len(opts)} options"
  40. @as_command
  41. def inquire():
  42. opts = (
  43. "Yes",
  44. "No",
  45. "Maybe",
  46. "Perhaps",
  47. "I guess",
  48. "Probably shouldn't",
  49. "Ask again later",
  50. "u know ;)",
  51. "rand",
  52. )
  53. chosen = random.choice(opts)
  54. if chosen == "rand":
  55. chosen = str(random.randrange(10))
  56. return chosen
  57. @as_command
  58. def democracy(candidates: Config("democracy.candidates")):
  59. return f"Congratulations to {random.choice(candidates)}, thank you all for participating in the democratic process!"
  60. @as_command
  61. def shuffle(opts: ArgList):
  62. if len(opts) < 2:
  63. return f"You need more things to shuffle!"
  64. random.shuffle(opts)
  65. fmt = "\n".join(f"{i + 1} - {v}" for i, v in enumerate(opts))
  66. return "Random Order:\n" + fmt
  67. THE_GUY = """\
  68. 🖕 😎
  69. 🐛💤👔🐛
  70. ⛽ 👢
  71. ⚡8=👊=D💦
  72. 🎸 🌽
  73. 👢 👢
  74. """
  75. @as_command("hey")
  76. def the_guy(args: ArgList):
  77. for x, y in zip(args, ("can", "i", "have", "the", "guy")):
  78. if x.lower() != y:
  79. RollbotFailure.INVALID_ARGUMENTS.raise_exc()
  80. return THE_GUY
  81. HOUSE_TOP = """\
  82. ┏┓
  83. ┃┃╱╲ In this
  84. ┃╱╱╲╲ house
  85. ╱╱╭╮╲╲ we love
  86. ▔▏┗┛▕▔ & appreciate
  87. ╱▔▔▔▔▔▔▔▔▔▔╲
  88. """
  89. STFU_TOP = """\
  90. ┏┓
  91. ┃┃╱╲ Shut
  92. ┃╱╱╲╲ The
  93. ╱╱╭╮╲╲ Fuck
  94. ▔▏┗┛▕▔ Up
  95. ╱▔▔▔▔▔▔▔▔▔▔╲
  96. """
  97. HOUSE_BOT = """
  98. ╱╱┏┳┓╭╮┏┳┓ ╲╲
  99. ▔▏┗┻┛┃┃┗┻┛▕▔
  100. """
  101. @as_command
  102. def appreciate(args: Args):
  103. return HOUSE_TOP + (" " * (20 - len(args))) + args + HOUSE_BOT
  104. @as_command
  105. def stfu(args: Args):
  106. return STFU_TOP + (" " * (20 - len(args))) + args + HOUSE_BOT
  107. @as_command
  108. def meme():
  109. return "I love you." if random.randint(1, 20) == 20 else "fuck off"
  110. Fs = """
  111. FFFFFFFFFFFFFFFFFFFFF
  112. FFFFFFFFFFFFFFFFFFFFF
  113. FFFFFFFFFFFFFFFFFFFFF
  114. FFFFFFF
  115. FFFFFFF
  116. FFFFFFF
  117. FFFFFFFFFFFFFF
  118. FFFFFFFFFFFFFF
  119. FFFFFFFFFFFFFF
  120. FFFFFFF
  121. FFFFFFF
  122. FFFFFFF
  123. FFFFFFF
  124. FFFFFFF
  125. """.strip()
  126. @as_command("f")
  127. def finchat(cmd: Command):
  128. return "frick!" if cmd.raw_name == "f" else Fs
  129. @as_command
  130. def reply(msg: Message):
  131. return "Replying!", Attachment(name="reply", body=msg.message_id)