Handling lists in python

3

I want to make a small application in python, what what to do is to be in the background listening to the messages it receives, to forward them to another array.

I have a dictionary like this:

from_to_redir = {
  "1447316562" : 1487212331,  # 1-2
  "1317723051" : 1308241218,  # 3-4
  "1287749122" : 1187924740,  # 5-6
  "1473192810" : 1197543096,  #7-8
  "1303515012" : 1330012567,  #9-10
  "1231992215" : 1262349386,  #11-12
  "1268998802" : 1411154699,  #13-14
  "1490320978" : 1402311342,  #15-16
  "1499511191" : 1246354970   #17-18
}

The print from_to_redir prints this:

{1447316562: 1487212331, 1317723051: 1308241218, 1287749122: 1187924740, 1473192810: 1197543096, 1303515012: 1330012567, 1231992215: 1262349386, 1268998802: 1411154699, 1490320978: 1402311342, 1499511191: 1246354970}

Right now I'm just trying to get each of the array's forwarding works, each group of numbers ("1447316562") refers to a chat, where the notifications from my sensors arrive, the number next to it, indicates where they have to redirect those messages.

My problem comes, and I do not know if it's because of the programming or the limitations of python, that when you get to the line of the array that you put (9-10) it no longer forwards anything, it's as if it broke, as if I was not able to get to the end of the array, and it's not really that each of the chats is constantly receiving, it's really from time to time, but I do not get it.

And I would like to use this project model, because of the ease of adding more sensors.

Thank you very much for your attention, we appreciate any contribution you can give me.

Greetings.

    
asked by Peisou 05.12.2018 в 15:36
source

1 answer

2

After researching and reading many logs, I managed to know what kind of error returned, I saw that it was not the fault of the program, or the dictionary, or the limitations of the API, if not a misuse of use.

When I received the messages in the relevant channels, the messages I took them correctly, but at the time of resending them, I said that I could not find the channel_id that I had established in the dictionary.

Debugging find out, that telethon in its "logic" assigns a different id, to the telegram, to the chats, with which I had to do a getUpdates of the dialogs (incoming messages) and if the id of the channel corresponds to the dictionary, that look for the corresponding id, doing this I have gotten it to work perfectly.

Thanks for the comments, without your help I would not have succeeded.

    
answered by 07.12.2018 / 11:10
source