simple.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import random
  2. from rollbot import as_plugin
  3. from config import get_secret
  4. @as_plugin
  5. def isadmin(message):
  6. return message.from_admin
  7. @as_plugin
  8. def debug(message):
  9. return message
  10. @as_plugin
  11. def echo(message):
  12. return "'%s' - %s" % (message.raw_args or "", message.name)
  13. @as_plugin
  14. def greet():
  15. return random.choice(("Hi!", "Hello!", "안녕하세요", "こんにちは", "你好", "👋"))
  16. @as_plugin
  17. def console(message):
  18. argstr = message.raw_args
  19. opts = [
  20. "NEVER GIVE UP",
  21. "I believe in you!",
  22. "You're doing your best, it's okay!"
  23. ]
  24. if argstr is not None:
  25. opts.append("It'll be okay, {}! Keep trying!".format(argstr))
  26. return random.choice(opts)
  27. @as_plugin
  28. def choice(message):
  29. opts = list(message.args())
  30. chosen = random.choice(opts)
  31. return f"Randomly chose {chosen} from {len(opts)} options"
  32. @as_plugin
  33. def inquire(message):
  34. opts = "Yes", "No", "Maybe", "Perhaps", "I guess", "Probably shouldn't", "rand"
  35. chosen = random.choice(opts)
  36. if chosen == "rand":
  37. chosen = str(random.randrange(10))
  38. return chosen
  39. @as_plugin
  40. def democracy():
  41. chosen = random.choice(get_secret("democracy.candidates"))
  42. return f"Congratulations to {chosen}, thank you all for participating in the democratic process!"