Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added send_html_topic_message and send_normal_topic_message... #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

harryeffinpotter
Copy link

@harryeffinpotter harryeffinpotter commented Mar 20, 2023

Along with some example commands in mycommands.sh, feel free to adjust and change it, repo owners! I just had a billion commands setup on my server and couldn't just easily write it all in some other bot framework so I had to figure it out. Hope this helps someone!

I was bummed when I didn't see this in the PRs so I decided to take matters into my own hands, at least I hope I did, they work for me but I'm sure there's something I missed as I didn't take the time to fully parse all the code in normal_message. Hope this helps someone!

P.S. - IDK why it is saying I removed those 262 lines unless the new stuff just caused alignment issues. But in case I did accidentally wipe something, that was not my intention, intention is just to ADD the new code for topics and remove 0 lines. Thanks.

…h example commands in mycommands.sh, feel free to adjust and change it, repo owners! I just had a billion commands setup on my server and couldn't just easily write it all in some other bot framework so I had to figure it out. Hope this helps someone!
@gnadelwartz
Copy link
Collaborator

looks good on first impression, but I'll add your Changes manually to not cripple mycommands unnecessarily

thanks alot

@harryeffinpotter
Copy link
Author

harryeffinpotter commented Mar 20, 2023 via email

@harryeffinpotter
Copy link
Author

harryeffinpotter commented Mar 20, 2023

Also I totally agree keep it uniform with the rest of the code and do your thing with the docs and whatnot I just wanted it to stick out as if the git diff wouldn't have been obvious lol , hard to ditch those shell scripting habits !

Where I always write stuff like:
echo -e "#####\nWelcome to my sick bash script!\n#####"
Lmao.

I just now noticed that the description for this bot says it uses the magic of sed, can confirm: sed is Magic. Used to look like it was made up on the spot as some elaborate inside joke/prank against me and well now I love it, makes managing the thousands of folders and files on my server so much more convenient and less messy. I had learned tg python bot this past week but I still prefer bash bot, it's just more straight forward and easily digestible. So I'm super glad to help and awesome job on the repo! It's essential !

@harryeffinpotter
Copy link
Author

Hey @gnadelwartz i had a quick question for you, when you implement it, when the bot is in a thread when summoned itr should be able to obtain the thread ID right? I was going to work on that right now but its probably a lot easier than I am imagining it to be. So that we can send messages in threadsa where it is called etc.

@harryeffinpotter
Copy link
Author

harryeffinpotter commented Mar 22, 2023

I was super wrong about that btw, its a lot more difficult to understand than i thought it would be, im pretty sure its going down in bashbot.sh where it uses chat_id, since threads are a neighboring parameter of chat_id but man im totally lost with the way you mad lads built this, i can tell its systematically brilliant but thteres so many caveats, when you have to disable that many shell check warnings hoo boy youre in for a time.

@gnadelwartz
Copy link
Collaborator

gnadelwartz commented Mar 23, 2023

Im not shure what you are refering to by thread? do you mean

  • each received Message spawns its own process
  • background or interactive scripts
  • the EVENTS system
  • something else

@harryeffinpotter
Copy link
Author

I mean the topics system its calling them "threads", in the json received in reply context in the API its message_thread_id:, I want to be able to retrieve this so it can reply to users.

@harryeffinpotter
Copy link
Author

Its where you also get the user that is sending the chat, and the message ID, so we just need to pull that from the same spot so it can be used,I'm just having a hard time finding the code where you do so

@gnadelwartz
Copy link
Collaborator

gnadelwartz commented Mar 30, 2023

OK, understood.

As I've not seen real data sent by telegram for subthreads I can provide a general explanation only, it should work like with USER[ID] insert something like this in process _message()

process_message() {
[....]
        THREAD[ID]="${UPD["result,${num},message,thread,id"]}"
            # UPD=JSON Array, num=message count (mostly  0), remaining string is the json field to get information from
            # e.g. ${UPD["result,0,message,thread,id"]} -> "thread,id" is a guess only, real string depends on JSON sent by telegram 

Note: add THREAD and any other new global array to declaration in line 360 in bashbot.sh:

bashbot.sh
....
     declare -Ax UPD ... THREAD
....

@harryeffinpotter
Copy link
Author

OK, understood.

As I've not seen real data sent by telegram for subthreads I can provide a general explanation only, it should work like with USER[ID] insert something like this in process _message()

process_message() {
[....]
        THREAD[ID]="${UPD["result,${num},message,thread,id"]}"
            # UPD=JSON Array, num=message count (mostly  0), remaining string is the json field to get information from
            # e.g. ${UPD["result,0,message,thread,id"]} -> "thread,id" is a guess only, real string depends on JSON sent by telegram 

Note: add THREAD and any other new global array to declaration in line 360 in bashbot.sh:

bashbot.sh
....
     declare -Ax UPD ... THREAD
....

Literally just found this comment after already figuring this all out and doing it myself -_- but I did have it under pre-process message rather than process message, so I added it there too, and it looks like this, btw, when looking at the proper json data:

THREAD[ID]="${UPD["result,${num},message,message_thread_id"]}"

@harryeffinpotter
Copy link
Author

any reason this is still unmerged? AFAIK it works well? This is pretty much all that the bash bot needs to stay current, IMO, the only feature I was sorely missing, at least.

@harryeffinpotter
Copy link
Author

Actually one thing it should really have - but it's hard for me to understand the code in this repo because bash is fuckin complicated, but it should have the ability to store the message thread from a reply or some such and then use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants