(
self,
token="",
telegram_username="",
instapy_session=None,
debug=True,
proxy=None,
)
| 30 | """ |
| 31 | |
| 32 | def __init__( |
| 33 | self, |
| 34 | token="", |
| 35 | telegram_username="", |
| 36 | instapy_session=None, |
| 37 | debug=True, |
| 38 | proxy=None, |
| 39 | ): |
| 40 | # import pdb; pdb.set_trace() |
| 41 | # private properties |
| 42 | self.__logger = logging.getLogger() |
| 43 | self.__chat_id = None |
| 44 | self.__updater = None |
| 45 | self.__context = None |
| 46 | |
| 47 | # public properties |
| 48 | self.token = token |
| 49 | self.telegram_username = telegram_username |
| 50 | self.instapy_session = instapy_session |
| 51 | self.debug = debug |
| 52 | self.proxy = proxy |
| 53 | # should be of type: |
| 54 | # proxy = { |
| 55 | # 'proxy_url': 'http://PROXY_HOST:PROXY_PORT/', |
| 56 | # # Optional, if you need authentication: |
| 57 | # 'username': 'PROXY_USER', |
| 58 | # 'password': 'PROXY_PASS', |
| 59 | |
| 60 | # see if we have a pre-existing chat_id from another run |
| 61 | if self.instapy_session is not None: |
| 62 | try: |
| 63 | telegramfile = open( |
| 64 | "{}telegram_chat_id.txt".format(self.instapy_session.logfolder) |
| 65 | ) |
| 66 | except OSError: |
| 67 | self.__chat_id = None |
| 68 | else: |
| 69 | with telegramfile: |
| 70 | self.__chat_id = telegramfile.read() |
| 71 | |
| 72 | # launch the telegram bot already if everything is ready at init |
| 73 | if ( |
| 74 | (self.token != "") |
| 75 | and (self.telegram_username != "") |
| 76 | and (self.instapy_session is not None) |
| 77 | ): |
| 78 | self.telegram_bot() |
| 79 | |
| 80 | @property |
| 81 | def debug(self): |
nothing calls this directly
no test coverage detected