
PureTelegram (framework for using the Telegram API)
Re: PureTelegram (framework for using the Telegram API)
The program stoped here (I think is because the caption is te same already on the msg):


-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
What does MemorySize(*SourceBuffer) tell you?
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
I don't know if that's ok



-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
I just tried this code, and it works perfectly - whether the captions are identical or not, and whether the MessageRequester() line is there or not.
I wonder if your error is happening because of memory allocation. Try this new version of the MPFR_Create() procedure and see if the code works:
If that doesn't work, try replacing the MPFR_Free() procedure with this:
If that doesn't work, keep this new version of MPFR_Free() and uncomment the line "ProcedureReturn q" in the MPFR_Create() procedure, and try again.
Let me know if any of this works.
Code: Select all
img1.i = CreateImage(#PB_Any,300,200,24,RGB(255,0,0))
img2.i = CreateImage(#PB_Any,300,200,24,RGB(0,255,0))
lastMsgID = Telegram_PostPBImage(#BotAPIToken,#ChatID,img1,"caption")
MessageRequester("Info","Pause before changing the image.")
If Not Telegram_ReplaceMessageImageWithPBImage(#BotAPIToken,#ChatID,lastMsgID,img2,"caption")
ultimoMsgID = Telegram_PostPBImage(#BotAPIToken,#ChatID,img2,"caption")
EndIf
Code: Select all
Procedure.i MPFR_Create()
reqs = ArraySize(MPFRequest())
For q = 1 To reqs
If Not MPFRequest(q)\active
MPFRequest(q)\active = #True
ProcedureReturn q
EndIf
Next q
reqs+1
If reqs>ArraySize(MPFRequest())
ReDim MPFRequest(reqs)
EndIf
MPFRequest(reqs)\active = #True
ProcedureReturn reqs
EndProcedure
Code: Select all
Procedure.b MPFR_Free(q.i)
With MPFRequest(q)
ForEach \field()
If \field()\SourceBuffer<>0
FreeMemory(\field()\SourceBuffer)
EndIf
Next
ClearList(\field())
\active = #False
EndWith
EndProcedure
Let me know if any of this works.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
None of these solutions works
I get the same error at the same line:
[10:35:14] [ERROR] Invalid memory access. (write error at address 141822908)
For your information, the error does not occurs the first time, some times at the second time, sometimes 3º, 4º... but everytime fails at some point with the same error on the same line.

[10:35:14] [ERROR] Invalid memory access. (write error at address 141822908)
For your information, the error does not occurs the first time, some times at the second time, sometimes 3º, 4º... but everytime fails at some point with the same error on the same line.
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
Try changing the MPFR_Create() procedure to this:
Code: Select all
Procedure.i MPFR_Create()
reqs = ArraySize(MPFRequest())
For q = 1 To reqs
If Not MPFRequest(q)\active
InitializeStructure(@MPFRequest(q),MPFRequestStructure)
MPFRequest(q)\active = #True
ProcedureReturn q
EndIf
Next q
reqs+1
If reqs>ArraySize(MPFRequest())
ReDim MPFRequest(reqs)
EndIf
InitializeStructure(@MPFRequest(reqs),MPFRequestStructure)
MPFRequest(reqs)\active = #True
ProcedureReturn reqs
EndProcedure
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
Your last code doesn´t work either, but I think I found the bug.
If I activate the Purifier y get this error:
[20:04:10] [ERROR] MultipartFormDataRequests.pbi (Linea: 171)
[20:04:10] [ERROR] Overflow in a dynamically allocated memory block.
I added the "+1" to this line:
\SourceBuffer = AllocateMemory(\DataLen+1)
Maybe to add extrasize for the null terminator?
Please check it in case I was wrong, but that solved my problem
If I activate the Purifier y get this error:
[20:04:10] [ERROR] MultipartFormDataRequests.pbi (Linea: 171)
[20:04:10] [ERROR] Overflow in a dynamically allocated memory block.
I added the "+1" to this line:
\SourceBuffer = AllocateMemory(\DataLen+1)
Maybe to add extrasize for the null terminator?
Please check it in case I was wrong, but that solved my problem

Code: Select all
Procedure.b MPFR_AddJSON(q.i,field_name.s,js.i)
AddElement(MPFRequest(q)\field())
With MPFRequest(q)\field()
\field_type = #MPFR_FieldType_Data
\mime = MimeType("json")
\field_parameter("name") = field_name
t.s = ComposeJSON(js)
\DataLen = StringByteLength(t,#PB_UTF8)
\SourceBuffer = AllocateMemory(\DataLen+1)
PokeS(\SourceBuffer,t,-1,#PB_UTF8)
EndWith
EndProcedure
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
Right, thank you. Did you use the MPFR_AddJSON procedure in your code?
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
No, on my code I only use these five procedures:Seymour Clufley wrote: Sat Jan 07, 2023 8:19 am Right, thank you. Did you use the MPFR_AddJSON procedure in your code?
Telegram_PostPBImage
Telegram_DeleteMessage
Telegram_EditMessageCaption
Telegram_ReplaceMessageImageWithPBImage
Telegram_PinMessage
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
But making this change to the JSON procedure has fixed the bug...?
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
Yes, 100% tested.Seymour Clufley wrote: Sat Jan 07, 2023 9:53 am But making this change to the JSON procedure has fixed the bug...?
Some of your procedures are using it indirectly (maybe)
-
- Addict
- Posts: 1264
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: PureTelegram (framework for using the Telegram API)
Oh, I see now. I use it in some of the procedures.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: PureTelegram (framework for using the Telegram API)
When you fix the bug, please edit the first post with the corrected code.
Also... the initNetwork() is deprecated now
Also... the initNetwork() is deprecated now

-
- Enthusiast
- Posts: 160
- Joined: Wed May 20, 2020 5:19 pm
- Location: The 3rd planet in the Solar System
- Contact:
Re: PureTelegram (framework for using the Telegram API)
Hello.
First, tnx for the module.
Any update of this module?
I got error of initNetwork()
[12:29:43] [COMPILER] Line 27: InitNetwork() is not a function, array, list, map or macro.
And sure, nothing work
Checked with PB 6.21 x64
Thank U
First, tnx for the module.
Any update of this module?
I got error of initNetwork()

[12:29:43] [COMPILER] Line 27: InitNetwork() is not a function, array, list, map or macro.
And sure, nothing work

Checked with PB 6.21 x64
Thank U
Last edited by dibor on Wed Jun 25, 2025 10:38 am, edited 2 times in total.
Mac Studio M1Max, PB 6.12 Arm64 and x64.
Macbook Air M2, PB 6.12 Arm64 and x64.
Windows 10, PB 6.12 x64 and x86.
Macbook Air M2, PB 6.12 Arm64 and x64.
Windows 10, PB 6.12 x64 and x86.