a working product
This commit is contained in:
parent
b0f07dc028
commit
d07e50b0c0
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,5 @@
|
||||
.env
|
||||
.cache/cookie
|
||||
venv/*
|
||||
venv/
|
||||
venv
|
||||
|
35
bot.py
Normal file
35
bot.py
Normal file
@ -0,0 +1,35 @@
|
||||
import datetime
|
||||
import telepot
|
||||
import subprocess
|
||||
from telepot.loop import MessageLoop
|
||||
from time import sleep
|
||||
|
||||
now = datetime.datetime.now()
|
||||
timestamp = ('Date: ' + str(now.day) + '/' + str(now.month) + '/' + str(now.year) + "\n" + 'Time: ' + str(now.hour) + ':' + str(now.minute) + ':' + str(now.second))
|
||||
|
||||
def handle(msg):
|
||||
chat_id = msg['chat']['id']
|
||||
command = msg['text']
|
||||
username = msg['from']['username']
|
||||
firstname = msg['from']['first_name']
|
||||
# lastname = msg['from']['last_name']
|
||||
print (f"\n Received: {command}\n From: {chat_id}, {firstname}")
|
||||
|
||||
if command == '/start':
|
||||
bot.sendMessage (chat_id, "Hello there, "+str(firstname)+"!")
|
||||
elif command == '/balance':
|
||||
getbalance = subprocess.run(["./get-balance.sh"],universal_newlines = True,stdout = subprocess.PIPE)
|
||||
balance = getbalance.stdout.splitlines()
|
||||
bot.sendMessage (chat_id, balance)
|
||||
else:
|
||||
bot.sendMessage(chat_id, "Invalid input")
|
||||
|
||||
#bot token
|
||||
bot = telepot.Bot('5732188026:AAFWvVTQkeF7sVPGmmqhysFJltUP3hjydew')
|
||||
MessageLoop(bot, handle).run_as_thread()
|
||||
|
||||
print (bot.getMe())
|
||||
print ("\n"+'BOT_IS_ONLINE!' "\n" +(timestamp))
|
||||
|
||||
while 1:
|
||||
sleep(10)
|
Loading…
x
Reference in New Issue
Block a user