Ejemplo n.º 1
0
def main():
    random.seed()
    import sys
    print(sys.argv)
    if len(sys.argv) != 5:
        print("Usage: testbot <server[:port]> <channel> <nickname> <password>")
        sys.exit(1)

    s = sys.argv[1].split(":", 1)
    server = s[0]
    if len(s) == 2:
        try:
            port = int(s[1])
        except ValueError:
            print("Error: Erroneous port.")
            sys.exit(1)
    else:
        port = 6667
    channel = sys.argv[2]
    nickname = sys.argv[3]
    password = sys.argv[4]

    bot = TestBot(channel, nickname, server, port, password)
    print("start")
    bot.start()
Ejemplo n.º 2
0
def main():
    bot.add_command('bg', botguard.BotGuard())
    # bot.add_command('echo', general.Echo())
    bot.add_command('hello', general.Hello())
    bot.add_command('help', general.Help())
    bot.add_command('meme', meme.Meme())
    bot.add_handler(botguard.handler)
    bot.add_handler(press_f.handler)
    bot.start()
Ejemplo n.º 3
0
def addBot(cmd, botname):
    bot = BotClient(cmd, botname)
    bot.setName(botname)

    for b in current_bots:
        if not b.is_alive():
            current_bots.remove(b)

    if not isBotAlive(bot):
        current_bots.append(bot)
        bot.start()
        print bot.getName()
Ejemplo n.º 4
0
def on_message(client, _, msg):
    data = json.loads(msg.payload)
    intent_name = data['intent']['intentName']
    sessionId = data['sessionId']

    if (intent_name == TALK_TO_BOT):
        slot = filter(slot_name_is('bot'), data['slots'])[0]
        bot_name = first_slot_value(slot)

        print('[snips] user wants to talk to {}'.format(bot_name))
        on_continue = lambda response: snips_client.publish(
            CONTINUE_SESSION, continue_session(sessionId, response, bot_name))
        bot.start(bot_name, on_continue)
    else:
        debug(data)
Ejemplo n.º 5
0
def on_talk_to_bot(client, sessionId, data):
    slot = next(filter(slot_name_is('bot'), data.get('slots')))
    bot_name = first_slot_value(slot)

    print('[snips] user wants to talk to {}'.format(bot_name))
    bot_client = bot.start(bot_name, on_continue(client, sessionId, bot_name))
    sessions[sessionId] = {'client': bot_client, 'name': bot_name}
Ejemplo n.º 6
0
def go_to_menu():
	new_line()
	log(bcolors.INFO, "You are in the menu. What do you want to do?")
	print(f"{bcolors.SUCCESS}1 {bcolors.NORMAL}- Start bot (Options must be configured)")
	print(f"{bcolors.SUCCESS}2 {bcolors.NORMAL}- Configure bot")
	
	choice = input()
	
	if choice == "1":
		log(bcolors.WARNING, f"Are you really sure you want to continue? {bcolors.WARNING}Your account will probably get banned if you use it on some subreddits!  {bcolors.HEADER}N/y")
		choice = input()
		if choice.lower() != "y":
			go_to_menu()
			return
		else:
			bot.start(get_options())
			go_to_menu()
	elif choice == "2":
		setup_configuration_file()
		go_to_menu()
	else:
		go_to_menu()
Ejemplo n.º 7
0
def join_goal(bot, update):
    import bot as bot_module
    goal_name = update.message.text
    goal_name = goal_name.split(': ')[1]
    goal = Goal.query.filter_by(is_active=True,
                                goal_name=goal_name,
                                chat_id=update.message.chat.id).first()

    telegram_id = update.message.from_user.id
    user = User.query.filter(User.telegram_id == telegram_id).first()

    goal.users.append(user)
    botdb.db_session.commit()

    return bot_module.start(bot, update)
Ejemplo n.º 8
0
    def save_to_pmlogs(message: tuple):
        with open("pm_logs.json", 'r') as pm_logs:
            try:
                data: dict = json.load(pm_logs)
            except json.decoder.JSONDecodeError:
                data = {}
            if message[1] in data:
                data[message[1]].append([message[2], message[3]])
            else:
                data[message[1]] = [[message[2], message[3]]]
        with open("pm_logs.json", 'w') as update_content:
            json.dump(data, update_content)

    def execute(self):
        for parsed_message in self.parse_message():
            print(parsed_message)
            try:
                self.save_to_pmlogs(parsed_message)
            except FileNotFoundError:
                open("pm_logs.json", 'x').close()
                self.save_to_pmlogs(parsed_message)
            asyncio.get_event_loop().create_task(
                bot.send_message(parsed_message))


if __name__ == "__main__":
    if config_data["admin_id"] and config_data["token"]:
        if config_data["admin_id"].isdigit():
            bot.start(int(config_data["admin_id"]), config_data["token"])
            ChatProcessor()
Ejemplo n.º 9
0
def main():
    bot.start()
Ejemplo n.º 10
0
        if len(str(rounded)) == 3:
            rounded = f'{rounded}0'
        text += f'{rounded} секунды'
    else:
        rounded = int(rounded)
        text += f'{rounded} секунд'
        if rounded < 10 or rounded > 20:
            if str(rounded)[-1] in ['1']:
                text += 'у'
            elif str(rounded)[-1] in ['2', '3', '4']:
                text += 'ы'
    print(text)


Repo.clone_from('https://github.com/evolvestin/test-parser', 'temp')
for file_name in os.listdir('temp/worker'):
    if os.path.isdir(f'temp/worker/{file_name}'):
        shutil.copytree(f'temp/worker/{file_name}', file_name)
    else:
        shutil.copy(f'temp/worker/{file_name}', file_name)
shutil.rmtree('temp', onerror=delete)
# ========================================================================================================
starting_print(stamp)

if __name__ == '__main__':
    if os.environ.get('TOKEN'):
        from bot import start
    else:
        from worker import start
    start(int(stamp))
Ejemplo n.º 11
0
from bot import start

start("76446784105", "99n0UM")
Ejemplo n.º 12
0
Archivo: main.py Proyecto: cbx33/wVote
    Loads configuration information from bot.conf.
    Specifically, bot.conf contains all information on what prefix is used
    to call the bot, which channel entries are posted in each week, which
    channel updates should be posted in, the bot key used to log in with
    discord.py, and which IDs are treated as admins.
    """

    config = json.load(open("botconf.json", "r"))

    logging.info("MAIN: Loaded bot.conf")

    return config


logging.basicConfig(format="%(asctime)s %(message)s",
                    level=logging.INFO,
                    handlers=[
                        logging.handlers.TimedRotatingFileHandler(
                            "logs/wvote.log", when="W0", backupCount=10),
                        logging.StreamHandler()
                    ])

loop = asyncio.get_event_loop()

config = load_config()
keys.configure(config)
bot_task = loop.create_task(bot.start(config))
http_task = loop.create_task(http_server.start_http(config))

loop.run_forever()
Ejemplo n.º 13
0
def echo_socket(ws):
    start(WebsocketConnection(ws))
Ejemplo n.º 14
0
def start_bot():
    bot.start()
Ejemplo n.º 15
0
from bot import start
from os import getenv

if (__name__ == '__main__'):
    try:
        print('[Nekobot] starting...')
        token = getenv('DISCORD_TOKEN')
        start(token)
    except (KeyboardInterrupt, SystemExit):
        print('[Nekobot] closing...')
Ejemplo n.º 16
0
from discord import Message

import mutiny
from bot import client, start


@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')


@client.event
async def on_message(message: Message):
    await client.process_commands(message)


mutiny.setup(client)

start()
Ejemplo n.º 17
0
import os
import sys
import bot

dir_path = os.path.dirname(sys.argv[0])
current_cwd = os.getcwd()

if dir_path != current_cwd:
        os.chdir(dir_path)

bot = bot.Bot(True)
bot.learn_all()
bot.start()
Ejemplo n.º 18
0
async def __main__():

	try:
		ipd_logger     = setup_logs('ipd',     'logs/ipd.log')
		opts_logger    = setup_logs('opts',    'logs/ipd-blacklist.log')
		discord_logger = setup_logs('discord', 'logs/ipd-discord.log')

		config = load_config()

		loop = asyncio.get_event_loop()

		env = config.get('env')
		tokens = config['tokens'][env]
		if type(tokens) is str:
			tokens = [ tokens ]

		for token in tokens:

			bot = ImperialProbeDroid(command_prefix=config['prefix'])

			bot.config = config
			bot.logger = ipd_logger
			bot.redis = config.redis

			from embed import EmbedManager
			bot.embed = EmbedManager(bot)

			from crinolo import CrinoloStats
			bot.stats = CrinoloStats(BaseUnit.get_ship_crews())

			from boterrors import BotErrors
			bot.errors = BotErrors(bot)

			from botoptions import BotOptions
			bot.options = BotOptions(bot)

			import client
			bot.client = client.SwgohClient(bot)

			from chatcog import ChatCog
			bot.add_cog(ChatCog(bot))

			from ticketscog import TicketsCog
			bot.add_cog(TicketsCog(bot))

			from twcog import TWCog
			bot.add_cog(TWCog(bot))

			from tbcog import TBCog
			bot.add_cog(TBCog(bot))

			loop.create_task(bot.start(token))

		try:
			loop.run_forever()

		except Exception as err:
			print('Run was interrupted!')
			print(err)
			print(traceback.format_exc())

		await bot.logout()
		print('Bot quitting!')

	except Exception as err:
		print('Bot initialization interrupted!')
		print(err)
		print(traceback.format_exc())
Ejemplo n.º 19
0
#Discord stuff
import bot

if __name__ == '__main__':
    #Used for the discord bot to login
    token = ''

    #Open file with token that you cant read
    with open('/home/arjan/discord.tkn', 'r') as f:
        #Read first line and get rid of newline character
        token = f.readline()[:-1]

    #Start the discord bot
    bot.start(token)
Ejemplo n.º 20
0
import os
import bot

API_TOKEN = os.environ['TELEGRAM_TOKEN']

bot.start(API_TOKEN)
Ejemplo n.º 21
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import bot

with open('GOSBook_Bot_token', 'r') as file1:
    TOKEN = file1.read().strip()

bot.start(TOKEN)
Ejemplo n.º 22
0
import bot
import server
import os
import encryption
from sheets_database import SheetsDatabase

server.GDHKeepAliveServer().asyncStart()  #keep alive http server

decrypt_key = os.getenv("decrypt_key")

decrypted_client_secret = encryption.decrypt_str(
    os.getenv("client_secret_fernet"), decrypt_key)

database = SheetsDatabase("Server DataBase",
                          "1-uyTYXpOHNWEMlOXHxfVD8LU_UGgIw2wiheAoddVxVk",
                          decrypted_client_secret)

discord_token = os.getenv("discord_token")  #get bot token from .env file

bot.start(database, discord_token)  #initialize bot client instance
Ejemplo n.º 23
0
import os
import bot

API_TOKEN = os.environ[
    '338961451:AAGEdm7OSG4OATpk1EuL7iaGhpIqqSegjzU338961451:AAGEdm7OSG4OATpk1EuL7iaGhpIqqSegjzU']

bot.start(API_TOKEN)
Ejemplo n.º 24
0
# Gameoptions

while True:
    print("""
     GAMEOPTIONS:

      1  : NORMAL
      2  : BOT (RANDOM)

      __

      99 : EXIT
    """)

    try:
        option = raw_input('Enter Gametype: ')
    except:
        option = input('Enter Gametype: ')

    if option == "1":
        normal.start()
    elif option == "2":
        bot.start()
    elif option == "99":
        print('Bye!')
        exit()
    else:
        print('Not found :(')

logFile.close()
Ejemplo n.º 25
0
import logging