class Kuritchi(discord.Client): def __init__(self, config): super().__init__() # iniファイルのコンフィグデータを取得 self.config = config # プラグインを全て読み込む self.plugin_manager = PluginManager(self) self.plugin_manager.load_all() self.loops = asyncio.get_event_loop() def defaults(self): self.server = discord.utils.get(self.servers, id=self.config["Discord"]["server_id"]) self.role_channel = discord.utils.get( self.server.channels, id=self.config["plugin"]["role_channel"]) self.user_role = discord.utils.get(self.server.roles, name="USER") async def on_ready(self): """接続準備完了時""" self.defaults() for plugin in self.plugins: self.loops.create_task(plugin._on_ready()) print("BOT-NAME :", self.user.name) print('ログインしました') async def on_member_join(self, member): """サーバーメンバー入室時""" for plugin in self.plugins: self.loops.create_task(plugin._on_member_join(member)) return async def on_message(self, message): """メッセージ受信時""" # 自分が送った or TEXTメッセージ以外はパス if self.user == message.author or message.type != discord.MessageType.default: return print(f"{message.author.name}: {message.content}") for plugin in self.plugins: self.loops.create_task(plugin._on_message(message)) # 以下現在未使用 async def on_message_delete(self, message): """メッセージ削除時""" return async def on_message_edit(self, before, after): """メッセージ編集時""" return async def on_reaction_add(self, reaction, user): """リアクション追加""" return async def on_reaction_remove(self, reaction, user): """リアクション削除""" return async def on_reaction_clear(self, message, reaction): """リアクション全削除""" return
def __init__(self, config): super().__init__() # iniファイルのコンフィグデータを取得 self.config = config # プラグインを全て読み込む self.plugin_manager = PluginManager(self) self.plugin_manager.load_all() self.loops = asyncio.get_event_loop()
#!/usr/bin/env python """ Copyright (c) UChicago Argonne, LLC. All rights reserved. See LICENSE file. """ from utilities.plugin_manager import PluginManager plugin_manager = PluginManager() plugin_manager.prompt_save_plugin()
""" Copyright (c) UChicago Argonne, LLC. All rights reserved. See LICENSE file. """ # # Update required auto-generated files for plugins. # # Usage: # # $0 [[CDB_DB_NAME]] [[UPDATE_CONFIGURATION (0/1)]] # from utilities.plugin_manager import PluginManager import sys cdb_db_name = 'cdb' if sys.argv.__len__() == 2: cdb_db_name = sys.argv[1] # Storage directory is irrelevant for updating deployed plugins. plugin_manager = PluginManager(cdb_db_name, use_default_storage_directory=True) update_configuration = False if sys.argv.__len__() == 3: input_update_configuration = int(sys.argv[2]) if input_update_configuration is not None: if input_update_configuration == 1: update_configuration = True plugin_manager.update_auto_generated_files(update_configuration)
#!/usr/bin/env python """ Copyright (c) UChicago Argonne, LLC. All rights reserved. See LICENSE file. """ from utilities.plugin_manager import PluginManager plugin_manager = PluginManager() plugin_manager.prompt_deploy_plugin()
#!/usr/bin/env python """ Copyright (c) UChicago Argonne, LLC. All rights reserved. See LICENSE file. """ from utilities.plugin_manager import PluginManager plugin_manager = PluginManager() plugin_manager.prompt_remove_plugin()
#!/usr/bin/env python """ Copyright (c) UChicago Argonne, LLC. All rights reserved. See LICENSE file. """ # # Adds the plugin to distribution and configures the plugin as necessary. # # Usage: # $0 [[CDB_DB_NAME]] # from utilities.plugin_manager import PluginManager import sys cdb_db_name = sys.argv[1] if cdb_db_name == None: cdb_db_name = 'cdb' plugin_manager = PluginManager(cdb_db_name) plugin_manager.prompt_deploy_plugin()
#!/usr/bin/env python """ Copyright (c) UChicago Argonne, LLC. All rights reserved. See LICENSE file. """ from utilities.plugin_manager import PluginManager plugin_manager = PluginManager() plugin_manager.list_plugins()
#!/usr/bin/env python """ Copyright (c) UChicago Argonne, LLC. All rights reserved. See LICENSE file. """ from utilities.plugin_manager import PluginManager plugin_manager = PluginManager() plugin_manager.update_auto_generated_files()