Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def listener(messages):
- for m in messages:
- cid = m.chat.id
- mensaje = ""
- if m.content_type == 'text':
- if cid > 0:
- mensaje = '' + str(m.chat.first_name) + "[" + str(cid) + "]: " + m.text
- else:
- mensaje = '' + str(m.from_user.first_name) + "[" + str(cid) + "]: " + m.text
- with open('/path/to/chats.json', 'r') as f:
- chats = json.load(f)
- if not m.chat.id in chats['chats']:
- chats['chats'].append(m.chat.id)
- with open('/path/to/chats.json', 'w') as f:
- json.dump(chats, f)
- bot.set_update_listener(listener)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement