{"action":"created","issue":{"url":"https://api.github.com/repos/LonamiWebs/Telethon/issues/93","repository_url":"https://api.github.com/repos/LonamiWebs/Telethon","labels_url":"https://api.github.com/repos/LonamiWebs/Telethon/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/LonamiWebs/Telethon/issues/93/comments","events_url":"https://api.github.com/repos/LonamiWebs/Telethon/issues/93/events","html_url":"https://github.com/LonamiWebs/Telethon/issues/93","id":230572341,"number":93,"title":"Sending back an auto-reply upon receiving messages","user":{"login":"Foleosy","id":13863226,"avatar_url":"https://avatars2.githubusercontent.com/u/13863226?v=3","gravatar_id":"","url":"https://api.github.com/users/Foleosy","html_url":"https://github.com/Foleosy","followers_url":"https://api.github.com/users/Foleosy/followers","following_url":"https://api.github.com/users/Foleosy/following{/other_user}","gists_url":"https://api.github.com/users/Foleosy/gists{/gist_id}","starred_url":"https://api.github.com/users/Foleosy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foleosy/subscriptions","organizations_url":"https://api.github.com/users/Foleosy/orgs","repos_url":"https://api.github.com/users/Foleosy/repos","events_url":"https://api.github.com/users/Foleosy/events{/privacy}","received_events_url":"https://api.github.com/users/Foleosy/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-05-23T02:45:41Z","updated_at":"2017-05-23T07:37:23Z","closed_at":"2017-05-23T07:32:11Z","body":"Hi, sorry for asking another question here.\r\n\r\nI am currently looking to send back an auto-reply upon receiving a message from another user, is it possible?\r\n\r\nI have tried using \"self.invoke(SendMessageRequest(peer=get_input_peer(entity),message=msg,random_id=msg_id,entities=entities,no_webpage=False))\" in the update_handler, method in the interactive_telegram_client class, such that whenever it receives a message and prints it to screen, it also sends back the auto-reply.\r\n\r\nHowever, since it is a static function, I do not have access to the client to use \"self\". Could you provide me any suggestions to work around this?\r\n\r\nI have tried instantiating an entire new client (a bad choice), making the methods all non-static (bad choice again), and implementing an observer pattern (too complicated for my lousy python skills).\r\n\r\nJust an update for the previous one, but I'm probably going to just my own encryption on the messaging since it's easier than working with Telegram secret chat..\r\n\r\nEdit: Have added a [question on SO ](https://stackoverflow.com/questions/44125272/calling-non-static-methods-from-static-methods-with-use-of-self)about this "},"comment":{"url":"https://api.github.com/repos/LonamiWebs/Telethon/issues/comments/303315433","html_url":"https://github.com/LonamiWebs/Telethon/issues/93#issuecomment-303315433","issue_url":"https://api.github.com/repos/LonamiWebs/Telethon/issues/93","id":303315433,"user":{"login":"Foleosy","id":13863226,"avatar_url":"https://avatars2.githubusercontent.com/u/13863226?v=3","gravatar_id":"","url":"https://api.github.com/users/Foleosy","html_url":"https://github.com/Foleosy","followers_url":"https://api.github.com/users/Foleosy/followers","following_url":"https://api.github.com/users/Foleosy/following{/other_user}","gists_url":"https://api.github.com/users/Foleosy/gists{/gist_id}","starred_url":"https://api.github.com/users/Foleosy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Foleosy/subscriptions","organizations_url":"https://api.github.com/users/Foleosy/orgs","repos_url":"https://api.github.com/users/Foleosy/repos","events_url":"https://api.github.com/users/Foleosy/events{/privacy}","received_events_url":"https://api.github.com/users/Foleosy/received_events","type":"User","site_admin":false},"created_at":"2017-05-23T07:37:23Z","updated_at":"2017-05-23T07:37:23Z","body":"I'd reply on SO comments, but SO comments sucks so hard, so...\r\n\r\nI changed the method definition to the non-static one, and added in \r\n```\r\nentity = update_object.user_id\r\nmessage = update_object.message\r\nmsg, entities = message, []\r\nmsg_id = utils.generate_random_long()\r\nself.invoke(SendMessageRequest(peer=get_input_peer(entity),\r\n       message=msg,random_id=msg_id,entities=entities,no_webpage=False))`\r\n```\r\nto obtain the various arguments for the request, and I get \r\n\r\n> \r\n > Exception in thread UpdatesThread:\r\n> Traceback (most recent call last):\r\n>   File \"/usr/lib/python3.5/threading.py\", line 914, in _bootstrap_inner\r\n>     self.run()\r\n>   File \"/usr/lib/python3.5/threading.py\", line 862, in run\r\n>     self._target(*self._args, **self._kwargs)\r\n>   File \"/home/ming/Documents/LiClipse Workspace/Telethon/telethon/network/mtproto_sender.py\", line 447, in updates_thread_method\r\n>     reader)\r\n>   File \"/home/ming/Documents/LiClipse Workspace/Telethon/telethon/network/mtproto_sender.py\", line 259, in process_msg\r\n>     return self.handle_update(msg_id, sequence, reader)\r\n>   File \"/home/ming/Documents/LiClipse Workspace/Telethon/telethon/network/mtproto_sender.py\", line 272, in handle_update\r\n>     handler(tlobject)\r\n>   File \"/home/ming/Documents/LiClipse Workspace/Telethon/telethon/interactive_telegram_client.py\", line 282, in update_handler\r\n>     message=msg,random_id=msg_id,entities=entities,no_webpage=False))\r\n>   File \"/home/ming/Documents/LiClipse Workspace/Telethon/telethon/telegram_client.py\", line 169, in invoke\r\n>     self.sender.send(request)\r\n>   File \"/home/ming/Documents/LiClipse Workspace/Telethon/telethon/network/mtproto_sender.py\", line 127, in send\r\n>     request.on_send(writer)\r\n>   File \"/home/ming/Documents/LiClipse Workspace/Telethon/telethon/tl/functions/messages/send_message.py\", line 52, in on_send\r\n>     self.peer.on_send(writer)\r\n> AttributeError: 'NoneType' object has no attribute 'on_send'\r\n\r\n"}}
{"actor":{"display_login":"Foleosy"}}