We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 21fdaa4 commit aeca3caCopy full SHA for aeca3ca
telegram/bot.py
@@ -52,7 +52,7 @@ class Bot(TelegramObject):
52
def __init__(self,
53
token,
54
base_url=None):
55
- self.token = token
+ self.token = self._valid_token(token)
56
57
if base_url is None:
58
self.base_url = 'https://api.telegram.org/bot%s' % self.token
@@ -744,3 +744,11 @@ def to_dict(self):
744
def __reduce__(self):
745
return (self.__class__, (self.token,
746
self.base_url.replace(self.token, '')))
747
+
748
+ @staticmethod
749
+ def _valid_token(token):
750
+ """a very basic validation on token"""
751
+ left, sep, _right = token.partition(':')
752
+ if (sep is None) or (not left.isdigit()) or (len(left) < 3):
753
+ raise TelegramError('Invalid token')
754
+ return token
0 commit comments