فهرست منبع

reimplemented all the simple commands from the older version, made a TODO list

Kirk Trombley 6 سال پیش
والد
کامیت
8f96e184e3
4فایلهای تغییر یافته به همراه111 افزوده شده و 19 حذف شده
  1. 15 0
      TODO_commands
  2. 1 1
      config/config.toml
  3. 0 13
      src/command_system.py
  4. 95 5
      src/plugins/simple.py

+ 15 - 0
TODO_commands

@@ -0,0 +1,15 @@
+old:
+roll
+session
+seychelles
+inspire
+pokemon
+shield
+say
+scp
+digest
+riddle
+
+new:
+reminders
+spoiler jar

+ 1 - 1
config/config.toml

@@ -1,5 +1,5 @@
 [plugins]
-simple = [ "echo" ]
+simple = [ "info", "isadmin", "debug", "echo", "thanks", "guess", "meme", "unmeme", "greet", "console" ]
 teamspeak = [ "teamspeak" ]
 
 [postgres]

+ 0 - 13
src/command_system.py

@@ -130,19 +130,6 @@ class RollbotPlugin:
         raise NotImplementedError
 
 
-def wrap_simple(fn):
-    def wrapper(db, message):
-        return RollbotResponse(message, txt=fn(db, message.raw_args))
-    wrapper.__name__ = fn.__name__
-    return wrapper
-
-
-def wrap_simple_no_db(fn):
-    def wrapper(db, message):
-        return RollbotResponse(message, txt=fn(message.raw_args))
-    wrapper.__name__ = fn.__name__
-    return wrapper
-
 
 def as_plugin(command):
     if isinstance(command, str):

+ 95 - 5
src/plugins/simple.py

@@ -1,7 +1,97 @@
-from command_system import wrap_simple_no_db, as_plugin
+from command_system import as_plugin, RollbotResponse
 
 
-@as_plugin
-@wrap_simple_no_db
-def echo(raw_args):
-    return raw_args
+HELP_MSG = """
+Hello!
+I am Rollbot 2.0 - a reimplementation of the previous Rollbot.
+I am a simple chatbot built in Python.
+I am licensed as open source under the MIT license.
+I can perform some basic operations, by using one of the following commands.
+I also have "secret" functionality as well - feel free to try other commands!
+
+!info - print this message.
+
+!echo <text> - echo back the provided text.
+
+!greet - print a simple greeting.
+
+!thanks - tell me thanks!
+
+!roll <expr> - roll a set of dice, or solve a simple math problem.
+This uses the Python dice library.
+
+!teamspeak - see who is in TeamSpeak currently. Not guaranteed to work!
+Telnet is complicated!
+
+!session <action> {<arg>} - manage the next DnD session
+    next (<date>|<day>) [<time>] - set the next session's date and time
+    view - view the date and time of the next session
+    late - determine how late you are for the next session
+    cancel [<blame>] - cancel the next session, and optionally blame someone
+    worst - see who is causing the most last-minute cancellations
+"""
+
+
+def lift(fn):
+    def wrapper(db, message):
+        return RollbotResponse(message, txt=fn(message.raw_args))
+    wrapper.__name__ = fn.__name__
+    return as_plugin(wrapper)
+
+
+@lift
+def info(message):
+    return HELP_MSG
+
+
+@lift
+def isadmin(message):
+    return str(message.from_admin())
+
+
+@lift
+def debug(message):
+    return str(message)
+
+
+@lift
+def echo(message):
+    return "'%s' - %s" % (message.raw_args, message.name)
+
+
+@lift
+def thanks(message):
+    return "You're welcome!"
+
+
+@lift
+def guess(message):
+    return "Rollbot's back - tell a friend!"
+
+
+@lift
+def meme(message):
+    return "fuck off"
+
+
+@lift
+def unmeme(message):
+    return "get a job"
+
+
+@lift
+def greet(message):
+    return random.choice(("Hi!", "Hello!", "안녕하세요", "こんにちは", "你好", "👋"))
+
+
+@lift
+def console(message):
+    argstr = message.raw_args
+    opts = [
+        "NEVER GIVE UP",
+        "I believe in you!",
+        "You're doing your best, it's okay!"
+    ]
+    if argstr is not None:
+        opts.append("It'll be okay, {}! Keep trying!".format(argstr))
+    return random.choice(opts)