Пример #1
0
def is_directed(data):
    return config.get_param(
        'group_id',
        'BOT') in data['text'] or data['peer_id'] == data['from_id']
Пример #2
0
import subprocess
import time
from service import app
from service import config

ngrok = config.get_param('exe', 'NGROK')
token = config.get_param('authtoken', 'NGROK')

if __name__ == '__main__':
    with subprocess.Popen([ngrok, 'authtoken', token]) as ngrok_auth:
        with subprocess.Popen(
            [ngrok, 'http', config.port],
                creationflags=subprocess.CREATE_NEW_CONSOLE) as ngrok_process:
            time.sleep(5)
            app.run(port=config.port)
Пример #3
0
import os
import importlib
from service import config
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = config.connection_string \
    if not config.get_boolean_param('debug') \
    else config.get_param('connection_string_debug', 'DATABASE')

db = SQLAlchemy(app)

__models = 'models'
__controllers = 'controllers'
__models_folder = os.path.abspath(
    os.path.join(os.path.dirname(__file__), os.pardir, __models))
__controllers_folder = os.path.abspath(
    os.path.join(os.path.dirname(__file__), os.pardir, __controllers))
for __imports in [__models_folder, __controllers_folder]:
    for __imported in [
            __import for __import in os.listdir(__imports)
            if __import.endswith('.py') and not __import.startswith('__')
    ]:
        importlib.import_module(
            f'{os.path.basename(__imports)}.{__imported[0:-3]}')
Пример #4
0
import vk
from service import config

version = float(config.get_param('api_version', 'BOT'))
session = vk.Session()
api = vk.API(session, v=version)


def send_peer(peer_id, token, message, attachment=''):
    api.messages.send(access_token=token,
                      peer_id=str(peer_id),
                      message=message,
                      attachment=attachment)


def send_chat(chat_id, token, message, attachment=''):
    api.messages.send(access_token=token,
                      chat_id=str(chat_id),
                      message=message,
                      attachment=attachment)


def send_user(user_id, token, message, attachment=''):
    api.messages.send(access_token=token,
                      user_id=str(user_id),
                      message=message,
                      attachment=attachment)
Пример #5
0
def handle(data):
    return config.confirmation_token \
        if 'type' in data.keys() and \
           data['group_id'] == int(config.get_param('group_id', 'BOT')) and \
           data['secret'] == config.get_param('access_token', 'BOT') \
        else 'bad'