Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext.commands import Bot
- from discord.ext import commands
- import asyncio
- import random
- import mysql.connector
- import sys
- from blinker import signal
- import zmq
- #Variable pour connexion à la base T4C
- mysql_host = "localhost"
- mysql_user = "root"
- mysql_password = ""
- mysql_base = ""
- #Variable pour le bot Discord
- botKey = "myKey"
- description = '''A bot form T4C'''
- client = commands.Bot(command_prefix="?", description=description)
- context = zmq.Context()
- socket = context.socket(zmq.REP)
- socket.bind("tcp://*:5555")
- @client.event
- @asyncio.coroutine
- def on_ready():
- print('Logged in as')
- print(client.user.name)
- print(client.user.id)
- print('------')
- # Commande cimetiere, annonce le top 10 XP
- @client.command()
- @asyncio.coroutine
- def startRoutine():
- # Wait for next request from client
- print("Waiting request...")
- message = socket.recv()
- client.say('%s' % message)
- socket.send(b"World")
- print("Received request: %s" % message)
- # Commande cimetiere, annonce le top 10 XP
- @client.command()
- @asyncio.coroutine
- def top10XP():
- print('TOP 10 REQUEST')
- conn = mysql.connector.connect(host=mysql_host,user=mysql_user,password=mysql_password, database=mysql_base)
- cursor = conn.cursor()
- cursor.execute("""SELECT PlayerName,CurrentLevel FROM playingcharacters ORDER BY CurrentLevel DESC LIMIT 10""")
- rows = cursor.fetchall()
- for row in rows:
- yield from client.say('{0} - lvl {1}'.format(row[0],row[1]))
- conn.close()
- client.run(botKey)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement