question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in sending message - Error 38: 'can not parse arg #1' with [disable_preview]

See original GitHub issue

The problem

I have simple script that sending a message, but sometimes it sends message, sometimes not

Your environment

Fill out your used versions:

Component Version
python 3.4.3 <!-- $ python --version; -->
pytg 0.4.10  
OS Ubuntu 14.04.2 LTS

Steps to reproduce

my code is:

import logging
logging.basicConfig(level=logging.DEBUG)
import time
from pytg import Telegram
d = open('/root/stock/stocks.txt', 'a+')
tg = Telegram(telegram="/root/tg2/bin/telegram-cli", pubkey_file="/root/tg2/tg-server.pub")
sender = tg.sender
sender.send_msg("miaow2", "/stock")
time.sleep(3)
histo = sender.history("miaow2", limit=0, offset=1)
stock = histo[39]
d.write(stock['text'] + '\n')
sender.safe_quit()
d.close()

Actual behaviour

Debug for fail to send message

INFO:pytg:Starting Telegram Executable: "/root/tg2/bin/telegram-cli -R -W -P 4458 -k /root/tg2/tg-server.pub --json --permanent-peer-ids --permanent-peer-ids"
DEBUG:pytg.sender:Parsing raw: Argument help - <command> (needed)
DEBUG:pytg.sender:Sending command >[disable_preview]  help
<
change_user_group: can't find the user telegramd to switch to
DEBUG:pytg.sender:Socket Connected.
DEBUG:pytg.sender:All Sent.
INFO:pytg:CLI available.
DEBUG:pytg.sender:Parsing send_msg: Argument miaow2 - <peer> (needed)
DEBUG:pytg.sender:Parsing send_msg: Argument /stock - <text> (needed)
DEBUG:pytg.sender:Sending command >[disable_preview] msg miaow2 '/stock'
<
DEBUG:pytg.sender:Socket Connected.
DEBUG:pytg.sender:All Sent.
Traceback (most recent call last):
  File "/root/stock/tg12_stock.py", line 10, in <module>
    sender.send_msg("miaow2", "/stock")
  File "/usr/local/lib/python3.4/dist-packages/pytg/sender.py", line 630, in command_alias
    return self.execute_function(command_name, *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/pytg/sender.py", line 354, in execute_function
    raise e
  File "/usr/local/lib/python3.4/dist-packages/pytg/sender.py", line 351, in execute_function
    return result_parser(message)
  File "/usr/local/lib/python3.4/dist-packages/pytg/result_parser.py", line 55, in success_fail
    raise FailException(json.error_code, json.error)
pytg.exceptions.FailException: Error 38: 'can not parse arg #1' (command "[disable_preview] msg miaow2 '/stock'\n")
INFO:pytg.sender:Quit Sending. Not allowing sending anymore.
WARNING:pytg.sender:Terminating currently sending request.
INFO:pytg.sender:Currently not Sending.
INFO:pytg:Closing Connections.
DEBUG:pytg:Closing sender.
DEBUG:pytg.sender:Already did quit Sending. Not allowing sending.
WARNING:pytg.sender:Terminating currently sending request.
INFO:pytg.sender:Currently not Sending.
DEBUG:pytg:Closing sender.
DEBUG:pytg.receiver:receiver thread existing: Not created.
INFO:pytg:Asking to CLI to stop.
DEBUG:pytg:Sender already stopped. Unable to issue safe_quit or quit to exit via socket.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.4/subprocess.py", line 960, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/lib/python3.4/subprocess.py", line 1602, in _communicate
    input_view = memoryview(self._input)
TypeError: memoryview: str object does not have the buffer interface
read: Connection reset by peer

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
edison0354commented, Jan 19, 2020

Send dialog_list in telegram-cli, then start to use pytg should fix the problem. At least it works for me…

1reaction
w1ldwormcommented, Nov 26, 2019

I’ve faced this problem and it seems to be from CLI, when you get the history from cli directly you get error: {"result": "FAIL", "error_code": 78, "error": "can not parse arg #1"}

But when you do a contact_list first and then get history it returns the history and now the script could be run it seems to a problem with the CLI

Read more comments on GitHub >

github_iconTop Results From Across the Web

A brand new website interface for an even better experience!
Error in sending message - Error 38: 'can not parse arg #1' with [disable_preview]
Read more >
What is Error 38 when sending SMS and how do you resolve it?
While trying to send an SMS, I get a notification for 'Error 38: Unable to send sms'. The message remains unsent after multiple...
Read more >
I am unable to send messages, message says ' error code 38 ...
Error 38 means: "Network out of order". This cause indicates that the network is not functioning correctly. Immediately reattempting the short message ...
Read more >
GXV3370 Firmware Release Note - Grandstream Networks
Page 1. GXV3370 Firmware Release Notes. Table of Content ... Fixed that no registration is sent after reboot when the phone registers 16 ......
Read more >
Diff - 8a94683^! - device/generic/goldfish - Git at Google
+ */ + +#ifndef HW_EMULATOR_CAMERA_CONVERTERS_H +#define HW_EMULATOR_CAMERA_CONVERTERS_H + +#include <endian.h> + +#ifndef __BYTE_ORDER +#error "could not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found