Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@botcmd
def hello(self, msg, args):
""" this command says hello """
return 'Hello World !'
@botcmd
def return_args_as_str(self, mess, args):
return "".join(args)
@botcmd
def remove_saw(self, msg, args):
self.destroy_dynamic_plugin('saw')
return 'removed'
@botcmd(template='args_as_md')
def yield_args_as_md(self, mess, args):
for arg in args:
yield {'args': [arg]}
@botcmd(split_args_with=ShlexArgParser())
def room_join(self, message, args):
"""
Join (creating it first if needed) a chatroom.
Usage:
!room join []
Examples (XMPP):
!room join example-room@chat.server.tld
!room join example-room@chat.server.tld super-secret-password
Examples (IRC):
!room join #example-room
!room join #example-room super-secret-password
!room join #example-room "password with spaces"
"""
@botcmd(admin_only=True)
def blacklist(self, mess, args):
"""Blacklist a plugin so that it will not be loaded automatically during bot startup"""
if args not in self.get_all_plugin_names():
return ("{} isn't a valid plugin name. The current plugins are:\n"
"{}".format(args, self.formatted_plugin_list(active_only=False)))
return self.blacklist_plugin(args)
@botcmd(admin_only=True)
def load(self, mess, args):
"""load a plugin"""
args = args.strip()
if not args:
return ("Please tell me which of the following plugins to reload:\n"
"{}".format(self.formatted_plugin_list(active_only=False)))
if args not in self.get_all_plugin_names():
return ("{} isn't a valid plugin name. The current plugins are:\n"
"{}".format(args, self.formatted_plugin_list(active_only=False)))
if args in self.get_all_active_plugin_names():
return "{} is already loaded".format(args)
self.reload_plugin_by_name(args)
r = self.activate_plugin(args)
return r
@botcmd(split_args_with=SeparatorArgParser())
def room_leave(self, message, args):
"""
Leave a chatroom.
Usage:
!room leave
Examples (XMPP):
!room leave example-room@chat.server.tld
Examples (IRC):
!room leave #example-room
"""
if len(args) < 1:
return 'Please tell me which chatroom to leave.'
self.query_room(args[0]).leave()
@botcmd
def asadmin(self, msg, _):
"""
This puts you in a 1-1 chat with the bot.
"""
self._bot.user = self.build_identifier(self.bot_config.BOT_ADMINS[0])
return f'You are now an admin: {self._bot.user}.'
@botcmd(split_args_with=SeparatorArgParser())
def room_invite(self, message, args):
"""
Invite one or more people into a chatroom.
Usage:
!room invite [, ..]
Examples (XMPP):
!room invite room@conference.server.tld bob@server.tld
Examples (IRC):
!room invite #example-room bob
"""
if len(args) < 2:
return "Please tell me which person(s) to invite into which room."
self.query_room(args[0]).invite(*args[1:])