Beispiel #1
0
def send_info():
    import bot

    _bot = bot.get_bot()
    bot_ip_command = bot.commands.common.BotIPCommand()
    poloniex_balance_command = bot.commands.common.PoloniexBalanceCommand()

    for text in (bot_ip_command.success_message,
                 poloniex_balance_command.success_message):
        for chat_id in settings.ADMINS:
            _bot.send_message(chat_id=chat_id, text=text)
def notify_users_about_new_projects():

    _bot = bot.get_bot()
    freelance_update_command = bot.commands.markets.FreelanceUpdateCommand()

    for user in mongo.users.get_all_users():
        projects = mongo.projects.get_new_projects(user['chat_id'])
        if not projects:
            continue

        last_seen_projects = freelance_update_command.get_last_seen_projects(projects)

        _bot.send_message(
            chat_id=user['chat_id'],
            text=freelance_update_command.get_message(projects),
            parse_mode=ParseMode.MARKDOWN,
            disable_web_page_preview=True,
            disable_notification=True,
        )
        mongo.users.update_last_seen_projects(user['chat_id'], last_seen_projects)
        return True
Beispiel #3
0
    async def read_searches():
        """Gets list of searches from saved JSON object and starts Getter threads

        Getter threads are responsible for getting items from searches put
        into the queue by the get_items task."""
        try:
            json_s = data.read()
            data_s = json.loads(json_s)
            for q in data_s['searches']:
                channel = bot.get_bot().get_channel(int(q['channel_id']))
                if not channel:
                    continue
                search = Search(q['url'], channel)
                await search.add_to_list()
        except KeyError:
            pass
        await bot.update_presence()
        bot.start_get_items()

        for i in range(MAX_THREADS):
            get_items_thread = threading.Thread(
                target=Search.get_items, name=f"Getter{i}", daemon=True)
            threads.append(get_items_thread)
            get_items_thread.start()
Beispiel #4
0
from flask import Flask, Response, request
from bot import get_bot

app = Flask(__name__)


@app.route("/", methods=["POST"])
def prime_num():
    bot.action(request.get_json())
    return Response("success!")


port_number = 3000
if __name__ == '__main__':
    bot = get_bot()
    app.run(port=port_number)
Beispiel #5
0
from bot import get_bot
import logging


def setup_logging():
    logging.basicConfig(filename="foxxbot.log",level=logging.ERROR)


setup_logging()
b = get_bot()      
b.activate()