Created
December 29, 2015 03:19
-
-
Save gradiuscypher/e82240bac6d4eb7bcb46 to your computer and use it in GitHub Desktop.
Discord Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_fun(testm, testc): | |
try: | |
print(type(testm)) | |
yield from testc.send_message(testm.channel, "fireman") | |
except: | |
print("wat") | |
@client.async_event | |
def on_ready(): | |
print('Logged in as') | |
print(client.user.name) | |
print(client.user.id) | |
print('------') | |
@client.async_event | |
def on_message(message): | |
server_id = config.get("BotSettings", "server_id") | |
selfname = config.get("BotSettings", "self_name") | |
permitted_channels = json.loads(config.get('BotSettings', 'permitted_channels')) | |
if message.server.id == server_id: | |
if not message.author.name == selfname and message.channel.name in permitted_channels: | |
try: | |
test_fun(message, client) | |
except: | |
print("There was an error with: " + str(plugin)) | |
print(traceback.format_exc()) | |
def main_task(email, password): | |
client.run(email, password) | |
def start_bot(config_file): | |
config.read(config_file) | |
plugins.load_plugins(config) | |
email = config.get("Account", "email") | |
password = config.get("Account", "password") | |
try: | |
loop.run_until_complete(main_task(email, password)) | |
except Exception: | |
loop.run_until_complete(client.close()) | |
finally: | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment