-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
57 lines (45 loc) · 1.46 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
sys.path.append(".")
import os
import logging
from dotenv import load_dotenv
from telegram.ext import Updater, PicklePersistence
from handler.base import BaseHandler
from datasource.odoo import Odoo
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def main():
token = os.getenv('TELEGRAM_TOKEN', None)
if not token:
load_dotenv()
token = os.getenv('TELEGRAM_TOKEN', None)
pp = None
if os.getenv('ENVIRONMENT', '') == 'DEV':
pp = PicklePersistence(filename='storage/telegram/heywallet')
if not token:
logger.error("Is required TELEGRAM_TOKEN is generate from BotFather.")
exit()
updater = Updater(
token,
persistence=pp,
use_context=True
)
# Get the dispatcher to register handlers
dp = updater.dispatcher
# set Workflow /start
dp.add_handler(BaseHandler().handler())
# Start the Bot
updater.start_polling()
# Run the bot until you press Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT. This should be used most of the time, since
# start_polling() is non-blocking and will stop the bot gracefully.
updater.idle()
def main2():
from datasource.odoo import OdooHeyWalletHandler
o = OdooHeyWalletHandler(False)
o.dummy()
#pass
if __name__ == '__main__':
main()
#main2()