added /me formatting
This commit is contained in:
parent
d91d62e6f0
commit
eab129fce8
@ -14,6 +14,7 @@ __license__ = "None"
|
|||||||
# API Documentation https://core.telegram.org/bots/api
|
# API Documentation https://core.telegram.org/bots/api
|
||||||
# Code examples https://github.com/eternnoir/pyTelegramBotAPI#getting-started
|
# Code examples https://github.com/eternnoir/pyTelegramBotAPI#getting-started
|
||||||
|
|
||||||
|
import email
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import telebot
|
import telebot
|
||||||
@ -32,16 +33,16 @@ from dotenv import load_dotenv
|
|||||||
from api_handling.api_handler import API_Handler
|
from api_handling.api_handler import API_Handler
|
||||||
|
|
||||||
|
|
||||||
load_dotenv(dotenv_path='.env')
|
load_dotenv(dotenv_path='.env') # load environment variables
|
||||||
|
|
||||||
bot_version = "1.0.1"
|
bot_version = "1.0.1"
|
||||||
user_list = []
|
user_list = []
|
||||||
|
|
||||||
#create api handler
|
#create api handler
|
||||||
api_handler = API_Handler("https://gruppe1.testsites.info/api", str(os.getenv("BOT_EMAIL")), str(os.getenv("BOT_PASSWORD")))
|
api_handler = API_Handler("https://gruppe1.testsites.info/api", str(os.getenv("BOT_EMAIL")), str(os.getenv("BOT_PASSWORD"))) # get creds from env vars.
|
||||||
print("Webserver Token: " + str(api_handler.token))
|
print("Webserver Token: " + str(api_handler.token))
|
||||||
|
|
||||||
class User: # Currently saving users in this class to test functionality -> later database
|
class User: # Currently saving users in this class to test functionality -> later database REMOVABLE
|
||||||
def __init__(self, p_user_id, p_user_name, p_chat_id):
|
def __init__(self, p_user_id, p_user_name, p_chat_id):
|
||||||
|
|
||||||
""" Initialize a new user
|
""" Initialize a new user
|
||||||
@ -79,7 +80,7 @@ def send_start(message):
|
|||||||
|
|
||||||
:rtype: none
|
:rtype: none
|
||||||
"""
|
"""
|
||||||
new_user = User(int(message.from_user.id), message.from_user.first_name, int(message.chat.id))
|
new_user = User(int(message.from_user.id), message.from_user.first_name, int(message.chat.id)) # now Database driven CHANGE
|
||||||
existing_already = False
|
existing_already = False
|
||||||
for known_user in user_list:
|
for known_user in user_list:
|
||||||
if known_user.user_id == new_user.user_id:
|
if known_user.user_id == new_user.user_id:
|
||||||
@ -129,7 +130,6 @@ def send_all_users(message):
|
|||||||
|
|
||||||
:rtype: none
|
:rtype: none
|
||||||
"""
|
"""
|
||||||
print('Debug: users command')
|
|
||||||
user_id = int(message.from_user.id)
|
user_id = int(message.from_user.id)
|
||||||
|
|
||||||
# tbd check if user is admin
|
# tbd check if user is admin
|
||||||
@ -152,12 +152,16 @@ def send_user(message):
|
|||||||
:rtype: none
|
:rtype: none
|
||||||
"""
|
"""
|
||||||
user_id = int(message.from_user.id)
|
user_id = int(message.from_user.id)
|
||||||
user_data = api_handler.get_user(user_id) # tbd: formatting
|
user_data = api_handler.get_user(user_id)
|
||||||
if not user_data or user_data == None:
|
if not user_data or user_data == None: # true if user is not registered
|
||||||
bot.reply_to(message, "This didn\'t work. Make sure to connect your telegram id (/id) on https://gruppe1.testsites.info")
|
bot.reply_to(message, "This didn\'t work. Make sure to connect your telegram id (/id) on https://gruppe1.testsites.info")
|
||||||
return
|
return
|
||||||
|
username = user_data['username']
|
||||||
bot.reply_to(message, 'Your user data:\n' + str(user_data))
|
email = user_data['email']
|
||||||
|
user_id = user_data['telegram_user_id']
|
||||||
|
cron = user_data['cron']
|
||||||
|
admin = user_data['admin']
|
||||||
|
bot.reply_to(message, f'Username: {username}\nEmail: {email}\nID: {user_id}\nCron: {cron}\nAdmin: {admin}') # format user data into readable message text
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['id', 'auth', 'Id', 'Auth']) # /auth or /id -> Authentication with user_id over web tool
|
@bot.message_handler(commands=['id', 'auth', 'Id', 'Auth']) # /auth or /id -> Authentication with user_id over web tool
|
||||||
|
Loading…
Reference in New Issue
Block a user