async def scan():
     while True:
         await bot.wait_until_ready()
         file=json_manager.curent_file("./json/delivery.json")
         for url in file:
             print("dfssd")
             last_event = list(scraper.get(url).get("events").values())[0]
             if last_event == "Colis livré au destinataire":
                 await bot.get_channel(json_manager.get(json_manager.config_file_uri, "relais_channel_id")).send("formidable ! "+file.get(url).get("name")+"viens d'arriver")
                 dict_without_it=json_manager.curent_file("./json/delivery.json")
                 del dict_without_it[url]
                 a_file = open("./json/delivery.json", "w")
                 json.dump(dict_without_it, a_file, indent = 4)  
                 a_file.close()
             else:
                 if not file.get(url).get("last_event") == last_event:
                     await bot.get_channel(json_manager.get(json_manager.config_file_uri, "relais_channel_id")).send(file.get(url).get("name")+"```\n"+last_event+"```")
                     json_manager.update("./json/delivery.json", url, {"author": file.get(url).get("author"), "name": file.get(url).get("name"), "last_event": last_event})
         await asyncio.sleep(100)
def create_database(database_name):
    database_access=json_manager.curent_file("./json/database.json")

    mydb = mysql.connector.connect(
      host=database_access["host"],
      user=database_access["user"],
      password=database_access["password"]
    )
    mycursor = mydb.cursor()

    mycursor.execute("CREATE DATABASE {}".format(database_name))
def create_table(table_name, keys):
    database_access=json_manager.curent_file("./json/database.json")

    mydb = mysql.connector.connect(
      host=database_access["host"],
      user=database_access["user"],
      password=database_access["password"],
      database=database_access["name"]
    )
    mycursor=mydb.cursor()

    mycursor.execute("CREATE TABLE {} {}".format(table_name, keys))
def add_group(group):
  database_access=json_manager.curent_file("./json/database.json")

  mydb = mysql.connector.connect(
    host=database_access["host"],
    user=database_access["user"],
    password=database_access["password"],
    database=database_access["name"]
  )
  mycursor=mydb.cursor()
  print(group.to_string())
  mycursor.execute("INSERT INTO groups (`groupe`) VALUES (%s)", (group.to_string()))
  mydb.commit()
示例#5
0
 async def create(self, ctx, arg1):
     #print(group.Group(uuid.uuid4, arg1, {"leader": ctx.author}, json_manager.curent_file("./json/default.json")).to_string())
     database_manager.add_group(
         group.Group(uuid.uuid4(), arg1, {"leader": ctx.author.id},
                     json_manager.curent_file("./json/default.json")))
     await ctx.send("group create {}".format(arg1))