示例#1
0
def main():
    # Function that loads the variables from .env
    load_dotenv()

    print("Welcome to the JacobsM1 Discord bot\nCreated by: Michael Jacobs")
    # runs the bot with run_bot() from bot.py
    run_bot()
示例#2
0
def ask_user():
    """Asks user for installing requirements/launching the bot"""
    answer = ""
    while answer != "3":
        clear()

        answer = input("What do you want to do?\n\n" +
                       "1. Install & update requirements\n" +
                       "2. Launch the bot\n" + "3. Quit\n\n> ")

        if answer == "1":
            install_requirements()
        elif answer == "2":
            from bot import run_bot
            run_bot()
示例#3
0
def main():
    ap = argparse.ArgumentParser("Joey NMT Bot")

    ap.add_argument("model_dir",
                    type=str,
                    help="Model directory with checkpoint for predictions.")

    ap.add_argument(
        "--bpe_src_code",
        type=str,
        help="path for bpe codes (if source is not pre-processed).")

    ap.add_argument("--tokenize",
                    action="store_true",
                    help="Tokenize inputs with Moses tokenizer.")

    args = ap.parse_args()

    run_bot(model_dir=args.model_dir,
            bpe_src_code=args.bpe_src_code,
            tokenize=args.tokenize)
def main(argv=None):
    args = argv
    if args is None:
        args = sys.argv
    try:
        if args[1] == "test":
            tests.run_tests()
        elif args[1] == "ask":
            src.run(args[2])
        elif args[1] == "bot":
            bot.run_bot()
        else:
            print("Unknown command line argument")
            logger.error("Unknown command line argument %s", args[1])
            return 1
    except IndexError as err:
        logger.exception(err)
        print("Not enough arguments")
        return 1
    except KeyError as err:
        logger.exception(err)
        print("Possible problems with JSON config. Please see logs for more information")
        return 1
    except Psycopg2Error as err:
        logger.exception(err)
        print("Problems with database. Please, check its existence and correctness of your login and password.")
        return 1
    except Psycopg2Warning as err:
        logger.exception(err)
        print("Sorry, we're experiencing problems with database.")
        return 1
    except Exception as err:
        logger.exception(err)
        print("An unexpected error occurred. For more information see the log file.")
        return 1
    return 0
示例#5
0
from bot import run_bot

run_bot()

示例#6
0
import bot
if (__name__ == "__main__"):
    bot.run_bot('')  # your token in quotes
示例#7
0
import config
import bot
import sqlite3
import sys

# initialize db connection
conn = sqlite3.connect(config.DB_LOCATION)

bot.run_bot(conn, int(sys.argv[1]), int(sys.argv[2]), config.CLIENT_KEY)
示例#8
0
    try:
        total_stat_file = open('cache/positions_%s.json' % today_date, 'r')
        positions = json.load(total_stat_file)
        total_stat_file.close()
    except IOError as e:
        print(
            "Файл не найден. Скрипт сегодня не запускался или файл с данными удален."
        )

    return positions, total_stat


# попытка наполнить бота сегодняшними данными (если скрипт перезапускается)
positions, total_stat = data_from_cache_or_init()

# открывалась ли биржа после запуска скрипта
opened = False

# интервал минута
while True:
    if check_day_and_time():
        opened = True
        run_bot(positions, total_stat, dispatcher, chat_id, add_link)
    else:
        print('Биржа закрыта')
        if opened:
            opened = False
            send_total_stat()
            break
    sleep(interval)
import bot
bot.run_bot("14:48")
示例#10
0
import asyncio

from bot import run_bot

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run_bot())
示例#11
0
def timed_job():
    r = bot.login_bot()
    bot.run_bot(r)
    print("Updating...")
示例#12
0
def test_bot_basics():
  """
  Tests the most basic bot functionality.
  """
  queue = [
    fake_api.FakeTweet( # will be ID 1
      "tester",
      None,
      "@{} tell help #ignored".format(config.MY_HANDLE)
    ),
    fake_api.FakeTweet( # will be ID 2
      "tester",
      4,
      "version"
    ),
    fake_api.FakeTweet( # will be ID 3
      "tester2",
      None,
      "tell \"Help\" by Peter Mawhorter"
    )
  ]
  output = io.StringIO()
  expect_printed = """\
Initiating streaming connection...
From: tester
Content: @gathering_round tell help #ignored
Handling non-reply as a general command.
From: tester
Content: version
In reply to: 4
Handling as reply to node 'help' in "Help" by Peter Mawhorter.
From: tester2
Content: tell "Help" by Peter Mawhorter
Handling non-reply as a general command.
"""
  expect_posted = """\
Id: 4
Replying to: 1
--------------------------------------------------------------------------------
@tester Firelight is an interactive story engine. Options appear in brackets. Help topics: [version] [links] 🐵🦊🐴🐃
================================================================================
Id: 5
Replying to: 2
--------------------------------------------------------------------------------
@tester This is Firelight version 0.1. [back] 🐒🦊🐴🐃
================================================================================
Id: 6
Replying to: 3
--------------------------------------------------------------------------------
@tester2 Firelight is an interactive story engine. Options appear in brackets. Help topics: [version] [links] 🦍🦊🐴🐃
================================================================================
"""

  # Clean out the test database:
  rdb.reset_db("test/test.db")

  # create a fake API object
  fcore = fake_api.FakeTwitterAPI(queue, output, "test/test.db")

  # load test stories
  load_stories.load_stories_from_directory(
    fcore,
    "test/stories"
  )
  load_stories.load_stories_from_directory(
    fcore,
    "test/modules",
    as_modules=True
  )

  # run the bot through one processing loop, capturing stdout
  old_stdout = sys.stdout
  capture = io.StringIO()
  sys.stdout = capture

  bot.run_bot(fcore, loop=False)

  sys.stdout = old_stdout

  posted = output.getvalue()
  printed = capture.getvalue()

  assert printed == expect_printed, (
    (
      "Bot printed output differs from expected output:\n```\n{}\n```\n{}\n```"
      "\nDifferences:\n  {}"
    ).format(
      printed,
      expect_printed,
      "\n  ".join(diff(printed, expect_printed))
    )
  )

  assert posted == expect_posted, (
    (
      "Bot posted output differs from expected output:\n```\n{}\n```\n{}\n```"
      "\nDifferences:\n  {}"
    ).format(
      posted,
      expect_posted,
      "\n  ".join(diff(posted, expect_posted))
    )
  )

  return True
示例#13
0
文件: main.py 项目: crsov/dogeik
        "  _____          _                           _            ____            _   "
    )
    time.sleep(0.5)
    print(
        " |_   _|  _ __  (_)   __ _   _ __     __ _  | |   ___    | __ )    ___   | |_ "
    )
    time.sleep(0.5)
    print(
        "   | |   | '__| | |  / _` | | '_ \   / _` | | |  / _ \   |  _ \   / _ \  | __|"
    )
    time.sleep(0.5)
    print(
        "   | |   | |    | | | (_| | | | | | | (_| | | | |  __/   | |_) | | (_) | | |_ "
    )
    time.sleep(0.5)
    print(
        "   |_|   |_|    |_|  \__,_| |_| |_|  \__, | |_|  \___|   |____/   \___/   \__|"
    )
    time.sleep(0.5)
    print(
        "                                     |___/                                    "
    )
    time.sleep(0.5)


console_picture()
input("Нажми Enter чтобы запустить...")

while True:
    bot.run_bot()
def bot():
    """
    Clean database & run scrapbot
    """
    restore()
    run_bot()
示例#15
0
 def handle(self, *args: tuple, **options: dict):
     run_bot()
示例#16
0
import bot
if (__name__ == "__main__"):
    bot.run_bot('417898092:AAEpi2cvIyj2Sqb_KDoI9tfmVBenNBLtR4k')
示例#17
0
import os
import sys
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

import bot


def initialize_session():
    session = requests.Session()
    session.headers.update(
        {'Authorization': 'Bot ' + os.environ["CLIENT_KEY"]})
    retry = Retry(
        total=5,
        read=1,
        connect=5,
        backoff_factor=0.3,
        status_forcelist=[500],
    )
    adapter = HTTPAdapter(max_retries=retry)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session


bot.run_bot(int(sys.argv[1]), int(sys.argv[2]), os.environ["CLIENT_KEY"],
            initialize_session())
示例#18
0
def main():
    args = parser.parse_args()
    token, config = bot.Config.read_config(config_name=args.config)
    bot.run_bot(token, config)
示例#19
0
icom = Intercom()
facerec = FaceRecognition()
doorBellServer = nodered.NodeRedDoorbellServerThread(icom)
doorBellServer.start()

if platform == "linux" or platform == "linux2":
    # linux
    print("Starting PulseAudio")
    subprocess.call(["pulseaudio", "-D"])


def onBellPressed():
    if chat_bot.chat_id is None:
        logging.warning('Bell is pressed but we have no user in the chat')
    else:
        process = audio.playAudioFileAsync(audio.DOORBELL_AUDIO_FILE)
        chat_bot.verify_image(chat_bot.updater, icom.takePicture())
        process.terminate()


def onTakeSnap():
    pic = icom.takePicture()
    chat_bot.uploadSnap(chat_bot.updater, pic)


icom.registerOnBellPressedCallback(onBellPressed)
chat_bot.registerOnSnapButtonCallback(onTakeSnap)
chat_bot.registerOpenDoorCallback(icom.openDoor)

chat_bot.run_bot()