Compare commits

...

3 Commits

Author SHA1 Message Date
Ceda EI 68a4d440e6 Add schema.sql 2019-01-22 16:15:34 +05:30
Ceda EI 27a2d3e50e Add server base code 2019-01-22 16:06:54 +05:30
Ceda EI 7581a15266 Add bot structure, sample config 2019-01-22 15:47:37 +05:30
4 changed files with 44 additions and 0 deletions

13
bot/bot.py Normal file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env python3
import config
from telegram.ext import Updater, MessageHandler, Filters
def message_handling(bot, update):
pass
updater = Updater(token=config.api_key)
dispatcher = updater.dispatcher
dispatcher.add_handler(MessageHandler(Filters.text, message_handling))

6
bot/sample.config.py Normal file
View File

@ -0,0 +1,6 @@
# Create a new bot by messaging @BotFather and follow the instructions
# Replace the key by the actual token recieved from BotFather
api_key = "123456789:xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Port to connect to server
port = 9876

1
bot/schema.sql Normal file
View File

@ -0,0 +1 @@
CREATE TABLE messages(message text);

24
bot/server.py Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env python3
from flask import Flask
import sqlite3
def get(db):
pass
def post(db):
pass
app = Flask(__name__)
db = sqlite3.connect(":memory:", check_same_thread=False)
# Set up tables
cursor = db.cursor()
with open('schema.sql') as fp:
cursor.executescript(fp.read())
app.add_url_rule('/get', 'get', lambda: get(db))
app.add_url_rule('/post', 'post', lambda: post(db))