How do I read messages from 777000 with python+telethon - telegram

Please help me how can I read messages from 777000 with python+telethon?

Related

Discord Bot python 3.6 report command

I am making a custom discord bot in python. I am trying to add a !report command.
I am very confused and cant find the answer anywhere. Can anyone help me make it?
I want any user to be able to do !report #example reason.
and save it in a database such as excel or sql3 or preferably in a staff channel.
how would I do this?
I have tried to use on_message()
You could use the on_message() command:
#client.event
async def on_message(message):
if message.content.startswith("!report"):
report_channel = client.get_channel(channel id)
member = text.split(" ")[1]
reason = ' '.join(text.split(" ")[1:])
await report_channel.send(f"Member: {member}, Reason: {reason}")
So the first thing is to look to see if the person used the "!report" command with an if statement.
Next, you find the member by taking the second word of the message.
After that, you find the reason by taking the rest of the words in the message.
Then you send it to the pre-defined report channel on discord.

Airflow Logs in Slack

I would like to know how I can report a log in my Slack message with Airflow.
I have tried to circumvent this issue by saving my exception error in a new function which includes also the original function :
def other_fun():
logf = open("log_original_main.log", "w")
try:
original_main()
except Exception as e:
logf.write(str(e))
logf.close()
But I have no idea with a Bash Operator.
So I hope you can provide a more general solution which works for both cases.
Airflow has an operator for slack notification called "SlackAPIPostOperator"
SlackAPIPostOperator(
task_id='Your_TASK_ID',
token='YOUR_TOKEN',
text="Message you want to notify in your slack",
channel=SLACK_CHANNEL,
username=SLACK_USER)
For more information you can visit Here, it will guide you how to generate token and when and where to use this operator. You can also use SlackWebhookOperator check (for more information)
And also this answer will help you.

How to send error details like as BadRequest

I need send rich structured error details on gRPC error.
I think it's maybe like this:
fv = BadRequest.FieldViolation(field="login", description="Name is not unique")
bad_request = BadRequest(field_violations=[fv])
context.abort(StatusCode.INVALID_ARGUMENT, bad_request.SerializeToString())
But is's wrong and send bytes in summary error text.
I use grpcio==1.17.1
I got feedback on github issue https://github.com/grpc/grpc/issues/17601
Everything works in version 1.18.0

Telegram channel- how to get access_hash?

I try really hard to understand howto use Telegram api with telethon. I have some Channels in Telegram, where i want to delete older Messages. Using inputpeerchannel() i need channel_id (No Problem) and channel_hash. I cant findout howto get this channel_hash by channel_id. Thank you from germany
In order to find channel access_hash, you should resolve channel username. Original MTProto method contacts.resolveUsername#f93ccba3 gets #username and returns channel info including access_hash.
In telethon you need to invoke ResolveUsernameRequest to call the above original MTProto method. You may use this code to resolve username to access_hash:
client = TelegramClient(session_file, api_id=00000, api_hash='XXXXX')
client.connect()
response = client.invoke(ResolveUsernameRequest("your_channel_id"))
print(response.chats[0].access_hash)
client.disconnect()
There are 4 ways to get access hash:
From a Group
From username
From contact list
From chats message
So, if you have id only, there is no way to get access hash

ModelService.saveAll method details

Could anyone please explain ModelService.saveAll and ModelService.save difference. In saveAll array is passed? Please explain below code
ModelService.saveAll([startedWorkOrder.getOwner(), woTimer.getOwner()]).then(function(){
Here woTimer is local resource and startedWorkOrder is actual MBO. So how is data saved in server?
Thanks

Resources