new bot functionality
This commit is contained in:
parent
54d43b27c2
commit
f1bfb25d95
@ -11,26 +11,55 @@ import sys
|
|||||||
import logging
|
import logging
|
||||||
from telebot import types
|
from telebot import types
|
||||||
|
|
||||||
|
user_list = []
|
||||||
|
|
||||||
|
class User: # Currently saving users in this class to test functionality -> later database
|
||||||
|
def __init__(self, p_user_id, p_chat_id):
|
||||||
|
self.user_id = int(p_user_id)
|
||||||
|
self.chat_id = int(p_chat_id)
|
||||||
|
|
||||||
bot = telebot.TeleBot(os.getenv('BOT_API_KEY'))
|
bot = telebot.TeleBot(os.getenv('BOT_API_KEY'))
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['start']) # /start -> saving as new user and sending welcome
|
||||||
|
def send_start(message):
|
||||||
|
new_user = User(int(message.from_user.id), int(message.chat.id))
|
||||||
|
existing_already = False
|
||||||
|
for known_user in user_list:
|
||||||
|
if known_user.user_id == new_user.user_id:
|
||||||
|
existing_already = True
|
||||||
|
if existing_already == False:
|
||||||
|
user_list.add(new_user)
|
||||||
|
|
||||||
@bot.message_handler(commands=['start', 'help'])
|
bot.reply_to(message, "Welcome to this share bot project. Type /help to get information on what this bot can do")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commands=['help']) # /help -> sending all functions
|
||||||
def send_welcome(message):
|
def send_welcome(message):
|
||||||
bot.reply_to(message, "/id or /auth for authentication. For further details see aktienbot.flokaiser.com")
|
bot.reply_to(message, "/id or /auth for authentication. /update to get updates on your shares. For further details see aktienbot.flokaiser.com")
|
||||||
|
|
||||||
@bot.message_handler(commands=['id', 'auth'])
|
|
||||||
|
@bot.message_handler(commands=['id', 'auth']) # /auth or /id -> Authentication with user_id over web tool
|
||||||
def send_id(message):
|
def send_id(message):
|
||||||
answer = 'Your ID/Authentication Code is: ' + str(message.from_user.id) + '. Enter this code in the settings on aktienbot.flokaiser.com to get updates on your shares.'
|
answer = 'Your ID/Authentication Code is: [' + str(message.from_user.id) + ']. Enter this code in the settings on aktienbot.flokaiser.com to get updates on your shares.'
|
||||||
bot.reply_to(message, answer)
|
bot.reply_to(message, answer)
|
||||||
|
|
||||||
@bot.message_handler(func=lambda message: True)
|
|
||||||
|
@bot.message_handler(commands=['update']) # /update -> send static update via user_id to this user, later fetch from database
|
||||||
|
def send_update(message):
|
||||||
|
user_id = int(message.from_user.id)
|
||||||
|
#Get Information for user with this id
|
||||||
|
bot.send_message(chat_id=user_id, text='This is your update')
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(func=lambda message: True) # Returning that command is unkown for any other statement
|
||||||
def echo_all(message):
|
def echo_all(message):
|
||||||
answer = 'Do not know this command or text: ' + message.text
|
answer = 'Do not know this command or text: ' + message.text
|
||||||
bot.reply_to(message, answer)
|
bot.reply_to(message, answer)
|
||||||
|
|
||||||
telebot.logger.setLevel(logging.DEBUG)
|
telebot.logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
@bot.inline_handler(lambda query: query.query == 'text')
|
|
||||||
|
@bot.inline_handler(lambda query: query.query == 'text') # inline prints for debugging
|
||||||
def query_text(inline_query):
|
def query_text(inline_query):
|
||||||
try:
|
try:
|
||||||
r = types.InlineQueryResultArticle('1', 'Result1', types.InputTextMessageContent('hi'))
|
r = types.InlineQueryResultArticle('1', 'Result1', types.InputTextMessageContent('hi'))
|
||||||
|
Loading…
Reference in New Issue
Block a user