mirror of
https://gitlab.com/questable/questable_bot
synced 2025-12-03 12:40:06 +01:00
Compare commits
6 Commits
ac3e09fb19
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 6116594eb4 | |||
| 1f0a05ca9d | |||
| d2b70dacd8 | |||
| c5b7eba052 | |||
| 1cc0743061 | |||
| 514117a079 |
29
README.md
29
README.md
@@ -1,3 +1,30 @@
|
|||||||
# Questable
|
# Questable
|
||||||
|
|
||||||
A game-like To-Do List Telegram Bot
|
A game-like To-Do List Telegram Bot.
|
||||||
|
|
||||||
|
Source code for [Questable Bot](https://t.me/questable_bot) and the relevant
|
||||||
|
[API](https://api.questable.webionite.com/)
|
||||||
|
|
||||||
|
# Self Hosting
|
||||||
|
|
||||||
|
+ Clone the repository.
|
||||||
|
+ `git clone https://gitlab.com/questable/questable_bot.git`
|
||||||
|
+ `cd questable`
|
||||||
|
|
||||||
|
## Telegram Bot
|
||||||
|
|
||||||
|
+ Install the dependencies
|
||||||
|
+ `pip3 install python-telegram-bot`
|
||||||
|
+ Copy `sample.config.py` to `config.py` and edit it accordingly.
|
||||||
|
+ Run the bot
|
||||||
|
+ `python3 bot.py`
|
||||||
|
|
||||||
|
## Questable API Server
|
||||||
|
|
||||||
|
+ Install the dependencies
|
||||||
|
+ `pip3 install Flask flask_cors`
|
||||||
|
+ Install `gunicorn`
|
||||||
|
+ `pip3 install gunicorn`
|
||||||
|
+ Run `gunicorn3 -b 127.0.0.1:5000 server:app`. Change port if you want to run
|
||||||
|
gunicorn on a different port.
|
||||||
|
+ Set up a reverse proxy from your webserver to `localhost:5000`.
|
||||||
|
|||||||
14
bot.py
14
bot.py
@@ -401,9 +401,13 @@ def tokens(bot, update):
|
|||||||
reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard)
|
reply_markup = telegram.ReplyKeyboardMarkup(custom_keyboard)
|
||||||
reply_text = ("Tokens are used to authenticate external "
|
reply_text = ("Tokens are used to authenticate external "
|
||||||
"applications. This only provides access to "
|
"applications. This only provides access to "
|
||||||
"Questable data.")
|
"Questable data.\n"
|
||||||
|
"\nOfficial clients are:\n"
|
||||||
|
"[Questable CLI](https://gitlab.com/questable/questable-cli)"
|
||||||
|
)
|
||||||
bot.send_message(chat_id=update.message.chat_id, text=reply_text,
|
bot.send_message(chat_id=update.message.chat_id, text=reply_text,
|
||||||
reply_markup=reply_markup)
|
reply_markup=reply_markup, parse_mode="markdown",
|
||||||
|
disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
def add_token(bot, update, player):
|
def add_token(bot, update, player):
|
||||||
@@ -627,7 +631,7 @@ with open('schema.sql') as f:
|
|||||||
cursor.executescript(f.read())
|
cursor.executescript(f.read())
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
updater = Updater(token=config.api_key)
|
updater = Updater(token=config.api_key, use_context=False)
|
||||||
dispatcher = updater.dispatcher
|
dispatcher = updater.dispatcher
|
||||||
|
|
||||||
dispatcher.add_handler(CommandHandler('start', start))
|
dispatcher.add_handler(CommandHandler('start', start))
|
||||||
@@ -638,12 +642,12 @@ dispatcher.add_handler(CommandHandler('cancel', lambda x, y: me_handler(x, y,
|
|||||||
db)))
|
db)))
|
||||||
dispatcher.add_handler(CommandHandler('help', lambda x, y: help_command(x, y,
|
dispatcher.add_handler(CommandHandler('help', lambda x, y: help_command(x, y,
|
||||||
db)))
|
db)))
|
||||||
dispatcher.add_handler(MessageHandler(Filters.text, lambda x, y:
|
|
||||||
message_handling(x, y, db)))
|
|
||||||
dispatcher.add_handler(RegexHandler(r"/[Ss]?[Qq]_\d+", lambda x, y:
|
dispatcher.add_handler(RegexHandler(r"/[Ss]?[Qq]_\d+", lambda x, y:
|
||||||
quest_handling(x, y, db)))
|
quest_handling(x, y, db)))
|
||||||
dispatcher.add_handler(MessageHandler(Filters.command, lambda x, y:
|
dispatcher.add_handler(MessageHandler(Filters.command, lambda x, y:
|
||||||
message_handling(x, y, db)))
|
message_handling(x, y, db)))
|
||||||
|
dispatcher.add_handler(MessageHandler(Filters.text, lambda x, y:
|
||||||
|
message_handling(x, y, db)))
|
||||||
|
|
||||||
if config.update_method == "polling":
|
if config.update_method == "polling":
|
||||||
updater.start_polling()
|
updater.start_polling()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class base_quest():
|
|||||||
self.DB = db
|
self.DB = db
|
||||||
self.CHAT_ID = chat_id
|
self.CHAT_ID = chat_id
|
||||||
self.name = name
|
self.name = name
|
||||||
self.QID = qid
|
self.QID = int(qid)
|
||||||
self.imp = imp
|
self.imp = imp
|
||||||
self.diff = diff
|
self.diff = diff
|
||||||
self.state = state
|
self.state = state
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import questable
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import errors
|
import errors
|
||||||
from flask import Flask, jsonify, request, redirect
|
from flask import Flask, jsonify, request, redirect
|
||||||
|
from flask_cors import CORS
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
CORS(app)
|
||||||
db = sqlite3.connect("questable.db", check_same_thread=False)
|
db = sqlite3.connect("questable.db", check_same_thread=False)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user