implemented /news and deleted debugbot (edit BOT_API_KEY instead) #2

Merged
Rripped merged 40 commits from bot-features into main 2022-03-16 09:08:43 +00:00
3 changed files with 52 additions and 3 deletions
Showing only changes of commit 267a7db04b - Show all commits

View File

@ -22,12 +22,14 @@ import sys
import logging import logging
import news.news_fetcher as news import news.news_fetcher as news
import share_fetcher import shares.share_fetcher as share_fetcher
import shares.wait_for_share
from telebot import types from telebot import types
from dotenv import load_dotenv from dotenv import load_dotenv
from share_fetcher import Share_Handler from share_fetcher import Share_Handler
load_dotenv() load_dotenv()
bot_version = "0.1.1" bot_version = "0.1.1"
@ -107,7 +109,7 @@ def send_welcome(message):
:rtype: none :rtype: none
""" """
bot.reply_to(message, "/id or /auth for authentication. /update to get updates on your shares. /users to see all users. /news to get current use for your keywords. For further details see aktienbot.flokaiser.com") bot.reply_to(message, "/id or /auth for authentication. /update to get updates on your shares. /users to see all users. /news to get current use for your keywords. /share to get price of specific share. For further details see aktienbot.flokaiser.com")
@bot.message_handler(commands=['users']) @bot.message_handler(commands=['users'])
@ -148,7 +150,7 @@ def send_id(message):
bot.reply_to(message, answer) bot.reply_to(message, answer)
@bot.message_handler(commands=['update']) # /update -> send static update via user_id to this user, later fetch from database @bot.message_handler(commands=['update'])
def send_update(message): def send_update(message):
""" Send update on shares """ Send update on shares
@ -166,6 +168,27 @@ def send_update(message):
#Get Information for user with this id #Get Information for user with this id
#call Share_Handler #call Share_Handler
bot.send_message(chat_id=user_id, text='This is your update') bot.send_message(chat_id=user_id, text='This is your update')
@bot.message_handler(commands=['share'])
def send_update(message):
""" Send price of a specific share
:type message: message object bot
:param message: message that was reacted to, in this case always containing '/share'
:raises: none
:rtype: none
"""
user_id = int(message.from_user.id)
#Get Information for user with this id
bot.send_message(chat_id=user_id, text='Send symbol of share:')
str_share_price = shares.wait_for_share.main_loop(bot)
@bot.message_handler(commands=['news']) @bot.message_handler(commands=['news'])

View File

@ -7,6 +7,7 @@ __version__ = "0.0.2"
__license__ = "None" __license__ = "None"
import yfinance import yfinance
import telebot
# S3W03GQH43I8O6IG # S3W03GQH43I8O6IG
@ -42,6 +43,7 @@ class Share_Handler:
my_share_data = my_share_info.info my_share_data = my_share_info.info
my_return_string = f'{my_share_data["regularMarketPrice"]} {my_share_data["currency"]}' my_return_string = f'{my_share_data["regularMarketPrice"]} {my_share_data["currency"]}'
return my_return_string return my_return_string
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -0,0 +1,24 @@
import time
import telebot
import share_fetcher
bot = 0
@bot.message_handler(func=lambda message: True)
def send_share_price(message):
fetcher = share_fetcher.Share_Handler()
str_price = fetcher.get_share_price(str(message.text))
return str_price
def main_loop(p_bot):
""" Get Information about bot status every 3 seconds
:raises: none
:rtype: none
"""
bot = p_bot
bot.infinity_polling()
while 1:
time.sleep(3)