def main(): with open('files/koya.config', 'r') as f: s = f.read() s = json.loads(s) os.system('clear') client.uname = s['username'] client.prefix = s['prefix'] client.run(s['token'])
def usage_get(): try: response = client.run() except FutureTimeoutError: return "ServerDown", 503 except Exception: return "UnknownError", 500 return Response(json.dumps(response), content_type='application/json')
from client import client from key import token # To load new modules, copy/paste the line below, uncommented, with X filled in for the name of your file # from modules import X from modules import help client.run(token)
def main(): try: print('Bot started...') client.run(TOKEN) except KeyboardInterrupt: client.logout()
from client import client import os if __name__ == '__main__': inp = 'D:\\spotify_data_dump\\integrated_data\\' N = 0 break_num = 10000 for filename in os.listdir(inp): if filename.endswith('.INDEX'): pid = filename.split('.')[0] rv = client.run(pid, 'push') if rv == True: print(pid) else: print('ERROR ----- %s' % pid) if N >= break_num: break N += 1 print('Done...')
user.display_name, user.name, ch1.name, ch2.name)) await asyncio.gather(*lst) await client.remove_reaction(reaction.message, mm_reaction_emoji_1, user) await client.remove_reaction(next_reaction.message, mm_reaction_emoji_2, user) return @client.command(pass_context=True) async def lib(ctx, url): #url = 'src\\' + url url = url.lower() if url != 'list': channel = ctx.message.author.voice.voice_channel server = ctx.message.server if client.voice_client_in(server) == None: await client.join_voice_channel(channel) voice_client = client.voice_client_in(server) player = voice_client.create_ffmpeg_player(filename=url + '.mp3') player.start() else: await client.say( "MP3 Name List: bencry, benko, noi, sfcl, money, zackstop, chillis, mskeisha, aknife, achild, kyle, wednesday, lebronjames, notmydad, eggsma, roadwork, delicioso, online, skate, cowboy, countryboy, oovoo, chickens, okay" ) #Run bot client.run(TOKEN)
import discord from client import client from secret import bot_token if __name__ == '__main__': # start the bot client.run(bot_token)
for expand_state in expand: self.tree[tuple(expand_state)] = {"win": 0, "total": 0, "per": 0} need_update.append(expand_state) win = 1 if winner == expect_winner else 0 for update_state in need_update: node = self.tree[tuple(update_state)] node["win"] += win node["total"] += 1 node["per"] = node["win"] * 1.0 / node["total"] def make_state(self, legal_game_state): return [(move, self.get_per(self.tree.get(tuple(state), None))) for move, state in legal_game_state] def get_per(self, node): return (-1, 0, 0) if node == None else (node["per"], node["win"], node["total"]) def choose_best(self, move_stats): #print "move_stats:", [(move_stat[0], "%.2f" % (100 * move_stat[1][0]), "%d/%d" % (move_stat[1][1], move_stat[1][2])) for move_stat in move_stats] best = max(move_stats, key=lambda x: x[1][0]) #print "chooosed best:", best return best[0] def choice(self, legal_moves, state): return self.random.choice(legal_moves) if __name__ == '__main__': run("127.0.0.1", 8011, "TT", "123456", 3, MctsParalleAI)
import logging from client.client import run if __name__ == "__main__": logging.basicConfig() run()
import os from client import client client.run(os.environ.get('PA_DISCORD_TOKEN'))
"""Headlines Watcher API""" import logging as log import threading from api import app from env import LOG_LEVEL from client import client from exceptions import DatasetBrowserException if __name__ == "__main__": log.getLogger().setLevel(LOG_LEVEL) try: client.run() threading.Thread(target=app.run()) except DatasetBrowserException as err: log.error("Terminating due to a fatal error: %s", err) except Exception as err: # pylint: disable=broad-except log.error("Terminating due to an unknown error: %s", err) finally: client.close()
#!/usr/bin/env python3 from client import client client.run(debug=True)
def run(self): # run random player client.run()
# -*- coding: UTF-8 -*- from client.client import Player from client.client import run class Human(Player): def get_move(self): move = raw_input("Enter your input like (r,c,r,c):") try: res_move = map(lambda x : int(x), move.strip().split(",")) return res_move except: self.get_move() if __name__ == '__main__': run("127.0.0.1", 8011, "TT", "123456", 3, Human)
if shared.guild is None: print(f"Exiting because bot has not joined guild ID {settings.GUILD_ID}.") sys.exit(0) setup_tickets_module() setup_buyers_module() @client.event async def on_message(message: Message): if message.author == client.user: # Don't process our own messages return if message.channel.type == discord.ChannelType.private: await message.channel.send("Sorry, I can't help you in a private chat.") return if message.channel.type != discord.ChannelType.text: await message.channel.send("Sorry, I only respond to commands that are sent in a guild.") return # Verify message is in valid guild if message.guild.id != settings.GUILD_ID: return await handle_message(message) client.run(DISCORD_TOKEN)
for guild in bot.guilds: if guild.id != int( cfg["Hosting"]["relay-id"]) and sum_of_weights(guild) == 0: await rebuild_weight_table(guild) if cfg["Settings"]["notify-on-startup"] == "True": owner = (await bot.application_info()).owner await owner.send("Bot is online.") # startup notify try: with open("restart.cfg", "r") as f: channel_id = int(f.read()) if channel := bot.get_channel(channel_id): await channel.send(f"Restart completed. Version is: {version}") elif user := bot.get_user(channel_id): await user.send(f"Restart completed. Version is: {version}") os.remove("restart.cfg") logger.info("Restart reminder found. Notifying channel.") except FileNotFoundError: pass if cfg["Hosting"]["ping"] == "True": keep_alive() try: bot.run(os.environ.get("TOKEN")) # Run bot with loaded password except HTTPException: os.system("kill 1") # hard restart on 429
async def on_message(message): # we do not want the bot to reply to itself if message.author == client.user: return asyncio.ensure_future(on_user_message(message)) @client.event async def on_raw_reaction_add(payload): if payload.channel_id == int(os.getenv('GROUPMEET_CHANNEL')): from services.group import gm, is_active if is_active: await gm.on_reaction(payload) if payload.channel_id == int(os.getenv('ASK_A_BOT')): from event import last_leaderboard_message_id if payload.message_id == last_leaderboard_message_id: await on_leaderboard_reaction(payload) #CRONs # called_once_a_week_gbu.start() # called_once_a_week_gm_poll.start() # called_once_a_week_gm_assign.start() # called_once_a_week_mmt.start() #BOT client.run(os.getenv('BOT_TOKEN'))
node["total"] += 1 node["per"] = node["win"] * 1.0 / node["total"] def select_one(self, legal_game_state): return (random.choice(legal_game_state))[1] def make_state(self, legal_game_state): return [(move, self.get_per(self.tree.get(tuple(state), None))) for move, state in legal_game_state] def get_per(self, node): return (-1, 0, 0) if node == None else (node["per"], node["win"], node["total"]) def choose_best(self, move_stats): #print "move_stats:", [(move_stat[0], "%.2f" % (100 * move_stat[1][0]), "%d/%d" % (move_stat[1][1], move_stat[1][2])) for move_stat in move_stats] best = max(move_stats, key=lambda x: x[1][0]) #print "chooosed best:", best return best[0] def player_legal_states(self, state): legal_moves = self.board.legal_moves(state) that = self legal_states = map(lambda move: that.board.next_state(state, move), legal_moves) return list(zip(legal_moves, legal_states)) if __name__ == '__main__': run("127.0.0.1", 8011, "TT", "123456", 3, MctsAI)
# -*- coding: UTF-8 -*- import random from client.client import Player, run class RandomAI(Player): def get_move(self): move = random.choice(self.board.legal_moves(self.cur_opponent_state)) return move if __name__ == '__main__': run("127.0.0.1", 8011, "TT", "123456", 5, RandomAI)