| | 
| 
| 
|  |  
| 
Joined:  Nov 2021 Posts: 30 Ameglian cow |  
| OP   Ameglian cow Joined:  Nov 2021 Posts: 30 | 
I have a routine with a timer that runs 24 hours a day retrieving news and feeding it into the SQLite database.
 The problem is that I have another routine with a timer that fetches the information to post to the channels.
 
 I use the following command: after retrieving the information from the database to post to the channel:
 1) scon -a if ($server) && (!$istok($noticias.getNetWorkChannel( %npt.Channel[ $+ [ %nptrd ] ] ),$network,32)) && ($me ison %npt.cf [ $+ [ %nptrd ] ] ) $noticias.send.msg.tip %npt.cf [ $+ [ %nptrd ] ] %vi [ $+ [ %nptrd ] ]
 
 The above format works, but I have an alias that feeds timers sequentially to avoid flooding and the bot crashing if it sends messages in batches. The alias is as follows:
 2) noop $noticias.on.text.timer(noticiasgettab,%npt.Channel[ $+ [ %nptrd ] ],$null,%vi [ $+ [ %nptrd ] ],$null,1,%ChannelSuf [ $+ [ %nptrd ] ])
 Using the above alias (2), mIRC gets lost and overwrites messages, placing messages from a channel other than its own. If I use method (1), the problem doesn't occur.
 
 Sqlite is constantly writing and reading, but I'd like to know if there's a way to use method (2) without overwriting the messages.
 
 Occasionally, if the channel sending the message is, for example, #help, the message sent is somehow from the #script channel, but it shouldn't be that way. I believe that the delay generated by the dll is causing one timer to overlap the other in memory, as they use the same alias.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,032 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2006 Posts: 4,032 | 
That's quite vague, the code you are showing are showing... nothing, it's just aliases being called.
 Couple notes though, the first one is to assume that the sqllite dll is single thread, as is mIRC, meaning only one thing is running ever.
 Your code in 1) and 2) has a [ touching %npt.channel, that is incorrect and should result in $null being used, yet you claim everything works as expected, that is mighty surprising.
 
 The fact that you mention wrong channel being used for /msg 100% means it's an issue with your script, there's no overlap going on when /msg is executed, the wrong channel is being passed to /msg, somehow (you're using the term overlap incorrectly).
 
 The time taken by the dll should only affect the eventual delay of the timer/sending of the message, it believes it's safe to assume there's no memory overlap going on there or you would have found a major issue in the scripting language.
 
 The [ touching the variable could be the reason for all of your issues, but there's another thing, /timer are double evaluating the command parameter, so for example /timer 1 1 msg #channel %myvar, if %myvar contains the plain text value $ip, the timer command will evaluate %myvar once and the timer now has the following command associated to it 'msg #channel $ip', which when executed, will result in the value of $ip being sent, instead of plain text $ip.
 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2021 Posts: 30 Ameglian cow |  
| OP   Ameglian cow Joined:  Nov 2021 Posts: 30 | 
There are no problems with the [ touching the variable. It was just when pasting it into the text here that it somehow got formatted incorrectly. I'll paste it again for you to see.
 1) `noop $noticias.on.text.timer(noticiaspegatab,%npt.Channel [ $+ [ %nptrd ] ],$null,%vi [ $+ [ %nptrd ] ],$null,1,%ChannelSuf [ $+ [ %nptrd ] ])`
 
 2) `scon -a if ($server) && (!$istok($noticias.getNetWorkChannel( %npt.Channel [ $+ [ %nptrd ] ] ),$network,32)) && ($me ison %npt.cf [ $+ [ %nptrd ] ] ) $noticias.send.msg.tip %npt.cf [ $+ [ %nptrd ] ] %vi [ $+ [ %nptrd ] ]`
 
 And below is the alias used to create a sequential timer to avoid flooding:
 
 `alias` news.on.text.timer {
 ; $1 network - $2 channel - $3 nick - $4 msg - $5 delay - $6 1ou0 cod=Msg - $7 channelSconmsg2 suffix - $8 verText
 noticias.hdelfree $noticias.on.text.timer.tab $noticias.tab.size n
 var %s1 $1, %s2 $2, %s3 $3, %s4 $4, %delay $iif($5,$5,$noticias.on.text.timer.delay), %s6 $6, %s7 $7, %s8 $iif($8,$8,0)
 var %pref, %prefINC, %dc, %tn, %u, %cod
 if (%s6) {
 %pref = all
 %cod = %s4
 }
 else {
 %pref = $+(%s1,%s2,%s3)
 %cod = $+(%s1,%s2,%s3,%s4)
 }
 if (%pref) %pref = $encode(%pref,m)
 %prefINC = $+(%pref,nottINC)
 %dc = $noticias.on.text.timer.tab.get(%prefINC)
 if (!%dc) %dc = %delay
 else %dc = $calc(%delay + $noticias.on.text.timer.tab.get(%prefINC,u))
 %tn = $+(%pref,.,$iif(!%s8,%dc,0))
 if ($noticias.on.text.timer.tab.get(%tn) != %s4) {
 %cod = $encode($+(%cod,$iif(!%s8,%dc)),m)
 if (!$timer($+(NoticiasText.,%cod))) {
 %u = $+(-u,%dc)
 hadd $noticias.on.text.timer.tab %tn ​​%s4
 $+(.timer,NoticiasText.,%cod) -o 1 %dc $&
 noop $sbtok(44,noticias.scon.msg2,$null,%s2,$sbtok(44,noticias.on.text.timer.tab.get,$null,%tn),$null,%s7) $&
 $chr(124) hdel $noticias.on.text.timer.tab %tn
 hadd %u $noticias.on.text.timer.tab %prefINC %dc
 
 }
 
 }
 
 This alias only creates a sequential timer for each message; other aliases called within it only create hashes and pass simple values. It's in this alias that mIRC gets lost. I use it in several other places and it works normally, but in the timer call that retrieves the SQLite information, it somehow gets lost and picks up other values ​​as an overwrite.
 
 The alias noticias.scon.msg2 does exactly what 2) does; I just removed the layers of aliases being called and took the last level to avoid this problem, and it worked. I don't know why this happens.
 
 alias noticias.scon.msg2 {
 ; $1 channel, $2 msg, $3 text complement, $4 channel.suffix
 if ($2) {
 var %nsm2.canal $1, %s2 $2, %s3 $3, %s4 $4, %nsm2.cf
 %nsm2.cf = $iif($chr(35) !isin %nsm2.canal,$+($chr(35),%nsm2.canal),%nsm2.canal)
 ; Do not remove the spaces below to get the value
 
 scon -a if ($server) && (!$istok($noticias.getCanalRedes( %nsm2.canal ),$network,32)) && ($me ison %nsm2.cf ) $noticias.send.msg.tipo %nsm2.cf %s2
 }
 
 NOTE: If there is removal of spaces between the variable and the [, it's something here in the forum's text editor.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2021 Posts: 30 Ameglian cow |  
| OP   Ameglian cow Joined:  Nov 2021 Posts: 30 | 
I believe I've discovered the problem in my news.on.text.timer alias.I tested it, and when I pass the parameter in $6 of the alias as 1, it overwrites the channel. I use this alias only for SQLite searches to retrieve information. I've already made the correction and am observing the behavior. I'll let you know here again if it's not just that. If it's fixed, it's what I described here.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jul 2006 Posts: 4,032 Hoopy frood |  
|   Hoopy frood Joined:  Jul 2006 Posts: 4,032 | 
When the wrong channel is used, is the channel being used the current $active channel ? How often does this wrong channel stuff happen?You should debug the code and log the channel value $1 passed to  noticias.scon.msg2, when the issue occurs, if the log show a correct value being passed then the shady business happens later on.
 Note that /scon has the same double evaluation problem as the /timer command.
 
 scon -a if ($server) && (!$istok($noticias.getCanalRedes( %nsm2.canal ),$network,32)) && ($me ison %nsm2.cf ) $noticias.send.msg.tipo %nsm2.cf %s2
 
 Here you should be using $unsafe() on any parameter that get double evaluated (in red). What does $noticias.send.msg.tipo returns ? you may want to try $!noticias.send.msg.tipo to evaluate it once when the timer fires (execute its command) instead of when the timer is launched.
 The alias sbtok could also be responsible for getting the channel wrong.
 
 #mircscripting @ irc.swiftirc.net == the best mIRC help channel
 |  |  |  | 
 |