Browse Source

Minor fix

drymer 3 years ago
parent
commit
8d09508463
1 changed files with 10 additions and 4 deletions
  1. 10
    4
      jabbergram.py

+ 10
- 4
jabbergram.py View File

@@ -12,10 +12,10 @@ from sys import argv
12 12
 from sys import exit
13 13
 
14 14
 
15
-class EchoBot(sleekxmpp.ClientXMPP):
15
+class jabbegram(sleekxmpp.ClientXMPP):
16 16
     def __init__(self, jid, password, rooms, nick, token, groups):
17 17
         # XMPP
18
-        super(EchoBot, self).__init__(jid, password)
18
+        super(jabbergram, self).__init__(jid, password)
19 19
         self.add_event_handler('session_start', self.start)
20 20
         self.add_event_handler('groupchat_message', self.muc_message)
21 21
 
@@ -35,7 +35,7 @@ class EchoBot(sleekxmpp.ClientXMPP):
35 35
         self.bot = telegram.Bot(self.token)
36 36
         self.telegram_users = {}
37 37
 
38
-        # meter el conector del tg en un hilo
38
+        # put tg connector in a thread
39 39
         t = Thread(target=self.read_tg)
40 40
         t.daemon = True
41 41
         t.start()
@@ -57,6 +57,11 @@ class EchoBot(sleekxmpp.ClientXMPP):
57 57
                     if not user:
58 58
                         user = str(update.message.from_user.first_name)
59 59
 
60
+                    # even weirder is that none of them exist
61
+                    # let's take last_name
62
+                    if not user:
63
+                        user = str(update.message.from_user.last_name)
64
+
60 65
                     msg = user + ": " + message
61 66
                     chat_id = update.message.chat_id
62 67
 
@@ -86,6 +91,7 @@ class EchoBot(sleekxmpp.ClientXMPP):
86 91
                 sleep(1)
87 92
 
88 93
             except Exception as e:
94
+                update_id += 1
89 95
                 print(e)
90 96
 
91 97
 
@@ -176,7 +182,7 @@ if __name__ == '__main__':
176 182
     token = config[4]
177 183
     groups = config[5]
178 184
 
179
-    xmpp = EchoBot(jid, password, muc_rooms, nick, token, groups)
185
+    xmpp = jabbergram(jid, password, muc_rooms, nick, token, groups)
180 186
     xmpp.register_plugin('xep_0045')
181 187
 
182 188
     if xmpp.connect():

Loading…
Cancel
Save