Beispiel #1
0
 def run(self):
     'parse input, update game state and call the bot classes do_turn method'
     not_finished = True
     data = ''
     #my_bot = Bot(self)
     while (not_finished):
         try:
             current_line = sys.stdin.readline().rstrip('\r\n')
             data += current_line + "\n"
             if current_line.lower().startswith("update game field"):
                 #sys.stderr.write("UPDATE")
                 #sys.stderr.flush()
                 self.update(data)
                 my_bot = Bot(self)
                 data = ''
             elif current_line.lower().startswith("action move"):
                 #sys.stderr.write("ACTION")
                 #sys.stderr.flush()
                 self.update(data)
                 self.issue_order(my_bot.do_turn())
                 data = ''
             elif current_line.lower().startswith("quit"):
                 not_finished = False
         except EOFError:
             break
         except KeyboardInterrupt:
             raise
         except:
             # don't raise error or return so that bot attempts to stay alive
             traceback.print_exc(file=sys.stderr)
             sys.stderr.flush()
Beispiel #2
0
def main():
    bot = Bot()
    game = Game()
    game.run(bot)
    hello = tf.constant('Hello, TensorFlow!')
    sess = tf.Session() 
    print(sess.run(hello))
Beispiel #3
0
    def _bots_initialization(self) -> None:
        """Initialization all bots with their configs"""

        assert isinstance(self.bots_configs, list), f"Incorrect bot_farm config file. bot_farm_config['bots'] " \
                                                    f"must be dict, but now: {type(self.bots_configs)}"

        for bot_config in self.bots_configs:
            self.bots.append(Bot(bot_config))
Beispiel #4
0
def main():
    started = datetime.now()
    if not os.path.exists("config/config.toml"):
        cfg = generate_config("config/config.toml")
        with open("config/config.toml", 'w') as f:
            new = toml.dump(cfg, f)
            print(new)
    config = toml.load(open("config/config.toml"))
    plugins = []

    group_id, token = config["bot"]["group_id"], config["bot"]["token"]
    bot = Bot(group_id, token, config)
    load_plugins(plugins, bot)
    bot.admins += config["bot"]["admins"]
    bot.plugins += plugins
    # Уиииии, я потом сам не пойму что это за хуйня))))))))
    logging.info(f"Бот запущен за {datetime.now() - started} секунд")
    bot.run()
Beispiel #5
0
def webhook():
    if request.method == 'POST':
        bot = Bot(BOT_TOKEN)
        update = bot.get_update(request.get_json())
        message = bot.create_message(update)
        bot.send_message(message)
        return 'OK'
Beispiel #6
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--random',
                        type=int,
                        help='makes random moves',
                        default=0,
                        required=False)

    args = parser.parse_args()

    bot = Bot(args.random)
    game = Game()
    game.run(bot)
Beispiel #7
0
def main():
    path = './data/'
    classifier = GaussianNB()
    bot = Bot(path, classifier)
    bot.train_question_model()

    user_input = input()
    while user_input != 'exit':
        bot.process_question(user_input)

        user_input = input()
Beispiel #8
0
def __main__():
    bot = Bot()
    game = Go()
    game.run(bot)
Beispiel #9
0
#!/usr/bin/python
from Bot.bot import Bot

if __name__ == '__main__':
    Bot()

Beispiel #10
0
from Cogs.Fun import greetings
from Cogs.Messaging import directMessaging
from Cogs.Fun import cottonEyeJoe
from Cogs.Fun import poll

from Bot.constants import Config, MODERATION_ROLES
from Bot.bot import Bot

from Util.messageProcessing import MessageProcessing

sys.path.insert(0, '/the/folder/path/name-package/')

allowed_roles = [discord.Object(id_) for id_ in MODERATION_ROLES]

bot = Bot(
    command_prefix=discord.ext.commands.when_mentioned_or(Config.PREFIX),
    # allowed_mentions=discord.AllowedMentions(everyone=False, roles=allowed_roles)
)

logging.basicConfig(level=logging.DEBUG)


@bot.event
async def on_ready():
    guild = discord.utils.get(bot.guilds, name=Config.GUILD)
    print(f'{bot.user} is connected to the guild:\n'
          f'{guild.name}(id: {guild.id})')
    print(bot.get_guild(guild.id).roles)


@bot.event
async def on_member_join(member):
Beispiel #11
0
def main():
    bot = Bot()
    game = Game()
    game.run(bot)