コード例 #1
0
 def setUp(self, mockKeybaseStatus, mockCheckCall):
     mockKeybaseStatus.return_value = {
         "LoggedIn": True,
         "Username": TEST_BOT
     }
     self.config = bot.Config(DB, TEST_BOT, TEST_OWNER)
     self.now = datetime.datetime.fromtimestamp(NOW_TS, tz=pytz.utc)
     bot.setup(self.config)
コード例 #2
0
def main():
    """docstring for main"""
    # Setup
    bot.setup()
    #
    # Run continuesly
    while True:
        humanSpeak = raw_input("> ")
        bot.response(humanSpeak)
コード例 #3
0
ファイル: launcher.py プロジェクト: colcrunch/Mercury
def launch():
    if args.migrate:
        os.system("aerich upgrade")
        return
    if args.setup:
        setup()
    if not path.exists("config.toml"):
        # First run, or other issues with config.
        setup()
        with open("config.toml", "r") as c:
            config = loads(c.read())
    else:
        with open("config.toml", "r") as c:
            config = loads(c.read())

        m_bot = MercuryBot(config=config)
        MercuryBot.run(m_bot)
    return
コード例 #4
0
import os
import bot
from flask import Flask, request
from telegram import Update

application = Flask(__name__, instance_path=os.environ['OPENSHIFT_REPO_DIR'])
update_queue, bot_instance = bot.setup(webhook_url='https://{}/{}'.format(
    os.environ['OPENSHIFT_GEAR_DNS'], bot.TOKEN))


@application.route('/')
def not_found():
    """Server won't respond in OpenShift if we don't handle the root path."""
    return ''


@application.route('/' + bot.TOKEN, methods=['GET', 'POST'])
def webhook():
    if request.json:
        update_queue.put(Update.de_json(request.json, bot_instance))
    return ''


if __name__ == '__main__':
    ip = os.environ['OPENSHIFT_PYTHON_IP']
    port = int(os.environ['OPENSHIFT_PYTHON_PORT'])
    application.run(host=ip, port=port)
コード例 #5
0
ファイル: main.py プロジェクト: Sheinxy/Snaky
import bot

if __name__ == "__main__":
    bot.setup("cogs.general", "cogs.macros", "cogs.emojis", "cogs.dev")
コード例 #6
0
ファイル: server.py プロジェクト: recrsn/rag-khyas
from flask import Flask, request
from flask_socketio import SocketIO

bot_avail = False

try:
    import bot
    bot.setup()
    bot_avail = True
except:
    print('No bot control')

app = Flask(__name__)


@app.route('/')
def hello_world():
    return app.send_static_file('index.html')


socketio = SocketIO(app)


@socketio.on('break')
def break_motor():
    print('break')
    if bot_avail:
        bot.stop_all_motors()


@socketio.on('move forward')
コード例 #7
0
import bot
import logging

logging.basicConfig(filename="bot_log.log",
                    level=logging.WARNING,
                    filemode='w')

if __name__ == "__main__":
    print("Starting bot")
    updater = bot.setup()

    updater.start_polling()
    updater.idle()
コード例 #8
0
ファイル: app.py プロジェクト: xlbruce/jaiminho-bot
import bot
import json
import logging

from flask import Flask, request
from telegram import Update

app = Flask(__name__)
bot, dispatcher = bot.setup(bot.token)


@app.route("/")
def hello():
    return "Run <pre>curl https://api.telegram.org/bot{my_bot_token}/setWebhook?url={url_to_send_updates_to}</pre> to setup Telegram Webhook."


@app.route("/telegram", methods=['POST'])
def forward():
    payload = Update.de_json(request.json, bot)
    dispatcher.process_update(payload)
    return "ok"
コード例 #9
0
 def setUp(self):
     self.config = bot.Config(DB, TEST_BOT, TEST_OWNER)
     self.now = datetime.datetime.fromtimestamp(NOW_TS, tz=pytz.utc)
     self.bot = bot.setup(self.config)
コード例 #10
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with python-telegram-bot-openshift.  If not, see <http://www.gnu.org/licenses/>.

import os
import bot
from flask import Flask, request
from telegram import Update


application = Flask(__name__, instance_path=os.environ['/opt/test/'])
update_queue, bot_instance = bot.setup(webhook_url='https://{}/{}'.format(
    os.environ['127.0.0.1'],
    bot.TOKEN
))


@application.route('/')
def not_found():
    """Server won't respond in OpenShift if we don't handle the root path."""
    return ''


@application.route('/' + bot.TOKEN, methods=['GET', 'POST'])
def webhook():
    if request.json:
        update_queue.put(Update.de_json(request.json, bot_instance))
    return ''
コード例 #11
0
#!/bin/env python3
"""
This file is meant to be run directly, never imported
"""

import logging
logging.basicConfig(level=logging.DEBUG)
discord_logger = logging.getLogger("discord")
discord_logger.setLevel(logging.WARN)

from bot import bot, setup

with open("discord-oauth2.tok", "r") as f:
    setup(bot)
    bot.run(f.read().strip())
コード例 #12
0
from flask import Flask, request
from telegram import Update

import bot
import settings

application = Flask(__name__, instance_path=settings.REPO_DIR)
update_queue, bot_instance = bot.setup(
    webhook_url='https://{}/{}'.format(settings.DOMAIN_NAME, settings.TELEGRAM_SECRET_URL)
)


@application.route('/')
def not_found():
    """Server won't respond in OpenShift if we don't handle the root path."""
    return ''


@application.route('/' + settings.TELEGRAM_SECRET_URL, methods=['GET', 'POST'])
def webhook():
    if request.json:
        update_queue.put(Update.de_json(request.json, bot_instance))
    return ''


if __name__ == '__main__':
    ip, port = settings.SERVER_IP, settings.SERVER_PORT
    application.run(host=ip, port=port)