mIRC Link Bot for Twitch - mirc

This is quite a long post (specially the code below), so bear with me.
With help from #Siris_Black, I've managed to get this thing working.
//LINK PROTECTION
on #*:text:*:#:linkpost $1-
on #*:action:*:#:linkpost $1-
on #*:notice:*:#:linkpost $1-
alias -l linkpost {
if ((!%p) && (!$hfind(permit,$nick))) { inc -u4 %p
var %purge /^!(link\so(n|ff)|(permit))\b/iS
var %domain com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk|tv
var %exception /(?:http?:\/\/)?w{3}\.(youtube|imgur|i.imgur)\.com/
var %link /(?<=^|\s)((?>\S{3,8}:\/\/|w{3}\56)\S+)|\56( $+ %domain $+ )\b/iS
if ($findtok(%chanon1,#,1,32)) && ($nick(#,$nick,vr)) && ($regex($1-,%link)) && (!$regex($1-,%exception)) {
timeout 30 # $nick | /mode # -b $nick
msg # $nick $+ , you did not have permission to post a link. Ask a mod to !permit you.
msg # /timeout $nick 1
}
elseif (($regex($1-,%purge)) && ($regml(1) = permit) && ($nick isop #) && ($$2 ison #)) {
hadd -mz permit $v1 30 | notice $v1 You have 30 seconds to post a link. Starting now!
msg # You now have 30 seconds to post a link!
}
elseif (($regml(1) = link on) && ($nick isop #)) {
goto $iif(!$istok(%chanon1,#,32),a,b) | :a | set %chanon1 $addtok(%chanon,#,32)
.msg # Link Protection Is Now on in: $+($chr(2),#)
halt | :b | .msg # $nick $+ , Link Protection is already on in $&
$+($chr(2),#,$chr(2)) !
}
elseif (($regml(1) = link off) && ($nick isop #)) {
goto $iif($istok(%chanon1,#,32),c,d) | :c | set %chanon1 $remtok(%chanon,#,1,32)
.msg # Link Protection Is now off in: $+($chr(2),#)
halt | :d | .msg # $nick $+ , Link Protection is already off . $&
!
}
}
}
However, even with the extensive script, there are some problems:
'Whitelisted' links that are being blocked
http://i.stack.imgur.com/Ww4rK.png
As you can see, Alexander_CJ and Psychosis06 posted Imgur links and were timedout (I have BetterTwitchTV, so I can reveal what was purged). Is there something that I have set up wrongly here?
The !permit command doesn't always work
There seems to be issues where the permit command fails to actually permit anyone. The primary issue were user names (which I figured out: all user names are lower case). But there still seems to be issues with the !permit + username command. Are there any conflicts that exist here?
Link Script allows certain links that have text before or after them
This is pretty self explanatory, there are situations where the link bot allows a link that seems to have normal text after it or before it. Unless I haven't set up the rule properly, there are situations where the issue crops up.
The Link Protection seems to interfere with other scripts
These are my other scripts:
//Commands
on *:TEXT:!commands:#circon: {
if ((%floodcommands) || ($($+(%,floodcommands.,$nick),2))) { return }
set -u5 %floodcommands On
set -u15 %floodcommands. $+ $nick On
msg $chan /me Currently available commands (place a '!' before the word) - donate|song|mods. Please don't spam commands. $+
}
//Song
on *:TEXT:!song:#circon: {
if ((%floodsong) || ($($+(%,floodsong.,$nick),2))) { return }
set -u5 %floodsong On
set -u15 %floodsong. $+ $nick On
msg $chan /me You can find Circon's songs here, wait for the song to finish and it will be the last played song: http://grooveshark.com/#!/circonflexes/listens $+
}
//Soccer Link
on *:TEXT:!football:#circon:{
if ((%floodfootball) || ($($+(%,floodfootball.,$nick),2))) { return }
set -u5 %floodfootball On
set -u15 %floodfootball. $+ $nick On
msg $chan /me Circon is watching the World Cup here!: <LINK> $+
}
//Mods Link
on *:TEXT:!mods:#circon:{
if ((%floodmods) || ($($+(%,floodmods.,$nick),2))) { return }
set -u5 %floodmods On
set -u15 %floodmods. $+ $nick On
msg $chan /me Circon's mods are here: http://youtu.be/N-IHaIKQvns. Servercross2 Recticle add-on - https://www.dropbox.com/s/dkd0b1fqp9oaz2e/ServerCross2.rar Dont forget to virus scan before use. :) $+
}
//Donate
on *:TEXT:!donate:#circon:{
if ((%flooddonate) || ($($+(%,flooddonate.,$nick),2))) { return }
set -u5 %flooddonate On
set -u15 %flooddonate. $+ $nick On
msg $chan /me Please donate to Circon here: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KRQXH2YM3WGSW $+
}
Once in a while, a command that is input correctly (i.e. !song) will not display the text. In fact, nothing happens. Is there anything that is conflicting? I'm not able to see any issues with what I've done. There are two sets of these scripts (for two Twitch channels).
I'm sorry that this is a lot. I'm a complete newbie to MSL and just need some pointers/tips. I'd primarily appreciate any guidance as to set up the most strict link protection - i.e. disallow ANY linking except youtube and imgur.
Thanks!

first, the other on text script (!command,!song,!footbal,!mods) needs to be in another remote file
since u have an on text script that matches anything on link protection script
try this
on #*:text:*:#:linkpost $1-
on #*:action:*:#:linkpost $1-
on #*:notice:*:#:linkpost $1-
alias -l linkpost {
if (!$hfind(permit,$nick)) {
var %purge /^!(link\so(n|ff)|(permit))\b/iS
var %domain com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk|tv
var %exception /(?:http?:\/\/)?(?:w{3}\.)?.+(youtube|\Qimgur\E)\.com/
var %link /(?<=^|\s)((?>\S{3,8}:\/\/|w{3}\56)\S+)|\56( $+ %domain $+ )\b/iS
if ($findtok(%chanon1,#,1,32)) && ($nick(#,$nick,vr)) && ($regex($1-,%link)) && (!$regex($1-,%exception)) {
timeout 30 # $nick | /mode # -b $nick
msg # $nick $+ , you did not have permission to post a link. Ask a mod to !permit you.
msg # /timeout $nick 1
}
elseif (($regex($1-,%purge)) && ($regml(1) = permit) && ($nick isop #) && ($$2 ison #)) {
hadd -mz permit $v1 30 | notice $v1 You have 30 seconds to post a link. Starting now!
msg # $$2 $+ , You now have 30 seconds to post a link!
}
elseif (($regml(1) = link on) && ($nick isop #)) {
goto $iif(!$istok(%chanon1,#,32),a,b) | :a | set %chanon1 $addtok(%chanon,#,32)
.msg # Link Protection Is Now on in: $+($chr(2),#)
halt | :b | .msg # $nick $+ , Link Protection is already on in $&
$+($chr(2),#,$chr(2)) !
}
elseif (($regml(1) = link off) && ($nick isop #)) {
goto $iif($istok(%chanon1,#,32),c,d) | :c | set %chanon1 $remtok(%chanon,#,1,32)
.msg # Link Protection Is now off in: $+($chr(2),#)
halt | :d | .msg # $nick $+ , Link Protection is already off . $&
!
}
}
}

Related

mIRC chat bot doesn't acknowledge commands

Below is some code I have written for my ever growing bird-related chat bot.
If I use the mIRC consolse, I can execute the alias blocks (eg. //fchirp [user] ), but for some reason, the bot doesn't acknowledge somebody typing "!chirp" from the main chat window. It doesn't even execute the first //echo statement in the on-text-event.
The weirdest part is: this code worked before and I've been using it regularly. I haven't changed any part of what is shown here aside from the //echo statements which I use for debugging.
addWorms and giveWorms are both aliases I wrote and function correctly on their own. The main issue I'm running into is get the bot to do anything at all when someone types"!chirp". (It should be noted that other unrelated on-text-events earlier in the code work just fine with identical syntax.)
alias fchirp {
/writeini chirp.ini $1 First $adate
/writeini chirp.ini $1 Last $adate
/writeini chirp.ini $1 Count 1
msg $chan /w $1 Welcome to the Nest! Thanks for checking in! :D
addWorms $1
msg $chan /w $1 Type !worms to see how many you have!
//echo -a first chirp
}
alias chirp {
var %a $readini(chirp.ini, $1, Count)
var %count $calc( %a + 1 )
if ( $readini(worms.ini, $1, Breed) == $null ) {
addWorms $1
//echo -a addWorms done
}
if ( $readini(chirp.ini, $1, Last) === $adate ) { msg $chan /w $nick You've already checked in today! BabyRage | halt }
/writeini chirp.ini $1 Last $adate
/writeini chirp.ini $1 Count %count
//echo -a last/count updated
if ( $calc( $readini(chirp.ini, $1, Count) % 5 ) == 0 ) {
giveWorms $1 10
msg $chan /w $1 Welcome back! Lucky day!
}
else {
giveWorms $1 5
msg $chan /w $1 Welcome back! Here's your worms! Don't forget to !hunt ! ^_^
}
//echo -a giveWorms
}
on *:TEXT:!chirp:#: {
//echo -a acknowledged
if ( $readini(chirp.ini, $nick, First) != $null ) {
//echo -a true
chirp $nick
}
else {
//echo -a false
fchirp $nick
}
msg $chan /w $nick Don't forget to !hunt for worms! :D
}
The Event catching can be interfere by two main reasons.
Error
You have an error above your code on the same remote file. e.g. missing bracket or syntax error.
Other event already been captured
mIRC will not process event that already been matched by another pattern on the same file.
example.ini
ON *:TEXT:* dog *: echo -ag This will be called if we wrote the word dog in a sentence.
ON *:TEXT:*:#: echo -ag This will be called
ON *:TEXT:*test*: echo -ag This will never be called. Even if we wrote the word test in sentence.
You can merge your TEXT events to handle both actions, although if they aren't logic related, i would separated them for another remote file.
on *:TEXT:*:#: {
if ($1- == !chirp) {
; In here put your code.
}
; Another code over here..
; Count some stuff in here..
}
Remark: / is useless on alias/popup/remote code, and it is just for identifying text vs commands for console mIRC window.

Add a pause before further execution in mIRC

So I've been thinking for like over an hour but did not arrive any conclusion with this script. I basically am trying to add a "status check" for 3 IRC servers via mIRC sockets. The problem I'm facing is that the execution jumps over to the next step without the socket connection being completed hence it returns a false value i.e Offline.
I tried using timer before goto commands but that returns ' not found'
Code:
on *:text:!stats:#: {
sockopen IRCAurora aurora.irchound.tk 6667
sockopen IRCKepler kepler.irchound.tk 6667
sockopen IRCJupiter jupiter.irchound.tk 6667
sockpause IRCAurora
sockpause IRCKepler
sockpause IRCJupiter
:true
msg $chan ----STATUS----
goto check1
halt
:check1
if ($sock(IRCAurora,pause) == 1) {
msg $chan 1Aurora - 9Online
}
else {
msg $chan 1Aurora - 4Offline
}
goto check2
halt
:check2
if ($sock(IRCJupiter,pause) == 1) {
msg $chan 1Jupiter - 9Online
}
else {
msg $chan 1Jupiter - 4Offline
}
goto check3
halt
:check3
if ($sock(IRCKepler,pause) == 1) {
msg $chan 1Kepler - 9Online
}
else {
msg $chan 1Kepler - 4Offline
}
halt
}
I know one solution is simply set up a php bot, but I want it on mIRC.
Any help would be appreciated. Thanks in advance.
Never mind .. I've already found the solution for the problem. Simple needed to add an alias function (that replies if socket pause if true / false) with a timer.
Solved code:
on *:text,loaddservers:#: {
if (%admin. [ $+ [ $nick ] ] = 1) {
msg $chan All default servers are now being loaded.
set %server1 aurora.irchound.tk
set %server2 jupiter.irchound.tk
set %server3 kepler.irchound.tk
}
else {
msg $chan Access denied.
}
}
;Create socket connection to servers on trigure.
on *:text:,status*:#: {
if ($2 = all) {
sockopen IRCAurora %server1 6667
sockopen IRCKepler %server2 6667
sockopen IRCJupiter %server3 6667
set %chan $chan
msg $chan Connecting to servers...
msg $chan >>>Status of all servers<<<
timer2 1 5 checkall
}
if ($2 = aurora) {
sockopen IRCAurora %server1 6667
set %chan $chan
msg $chan Connecting to server $2 $+ ...
timerAURORA 1 5 checkaurora
}
if ($2 = kepler) {
sockopen IRCKepler %server2 6667
set %chan $chan
msg $chan Connecting to server $2 $+ ...
timerKEPLER 1 5 checkkepler
}
if ($2 = jupiter) {
sockopen IRCJupiter %server3 6667
set %chan $chan
msg $chan Connecting to server $2 $+ ...
timerJUPITER 1 5 checkjupiter
}
}
;Aliases for each server status response.
alias checkaurora {
if ($sock(IRCAurora,pause) == 1) {
msg %chan 1Aurora - 9Online
}
else {
msg %chan 1Aurora - 4Offline
}
halt
}
alias checkjupiter {
if ($sock(IRCJupiter,pause) == 1) {
msg %chan 1Jupiter - 9Online
}
else {
msg %chan 1Jupiter - 4Offline
}
halt
}
alias checkkepler {
if ($sock(IRCKepler,pause) == 1) {
msg %chan 1Kepler - 9Online
}
else {
msg %chan 1Kepler- 4Offline
}
halt
}
alias checkall {
if ($sock(IRCAurora,pause) == 1) {
msg %chan 1Aurora - 9Online
}
else {
msg %chan 1Aurora - 4Offline
}
goto check2
halt
:check2
if ($sock(IRCJupiter,pause) == 1) {
msg %chan 1Jupiter - 9Online
}
else {
msg %chan 1Jupiter - 4Offline
}
goto check3
halt
:check3
if ($sock(IRCKepler,pause) == 1) {
msg %chan 1Kepler - 9Online
}
else {
msg %chan 1Kepler - 4Offline
}
}
NOTE: I've excluded some part of the script that's not related to the question.. so you may find some undefined variables.

mIRC 'null' delimiter for $gettok

Sorry if my title wasn't clear enough. I'm back for some more guidance!
I'm trying to set up a unique language kicking bot. The chats I moderate have influxes of Russian language chat spammers. So I was trying to set up a bot that kicks someone when they type in Russian. So I set this up:
alias -l russian.words { RETURN Л.Д.э.И }
ON #*:TEXT:*:#: {
IF ($nick isop #) return
VAR %x = $strip($1-) , %i = $numtok($russian.words,46)
WHILE (%i) {
IF ($istok(%x,$gettok($russian.words,%i,46),32)) {
raw -q mode # +b $wildsite
msg # $nick $+ , English in chat, please! Только на английском языке в чате!
msg # /timeout $nick 1
RETURN
}
DEC %i
}
}
The problem is that the bot checks for the russian letters only if they are 'on their own'. If the Russian letters are part of a larger sentence/word, the bot doesn't work.
I believe it's because of the delimiter in the $gettok, which is set at 32 (a space). However, when I change the delimiter to 0 (null), the bot doesn't work at all.
So right now, the only thing the bot kicks are people who use ONLY those specific letters. I want the bot to kick to anyone who uses those letters on their own or when in a sentence/word.
BTW, I've chosen these letters because they are considered the most common Russian letters that do not share the same letters as English.
Any help is appreciated.
try this
paste into a new remote file
on $#*:text:/(Л|Д|э|И)/iS:#:{
if ($nick !isop $chan) {
ban -k $nick 2 English in chat, please! Только на английском языке в чате!
}
}

How to auto copy paste between different channels on different network in mIRC, if it matches predefined word?

I'm a person with zero programming skill, thus everything related to programming seems like the hardest thing.
I wanted to auto copy paste between different channels on different network using mIRC, if it matches predefined word. For example:
My predefined word is: hello
If someone in #channelA (on network1) or #channelB (on network2) or #channelC (on network3) says hello, it will appear on #channel4 (on network4) as: said "hello" without channel's name or anything and no duplicate from rest of the networks(if said hello there as well) will appear on network 4's channel, i.e only first one will appear for each keyword.
I have tried searching for a solution and found this:
mIRC bot - copy/paste lines in 2 channels
But it's not helpful to me. Any guidance would be appreciated.
Usually we never built someone a script but asks him for what he done so far and then pointing him the failures or helping him a little bit.
But because the script you mentioned sounds nice, i took the liberty of implementing it myself.
If you not familiar with mSL i suggest you to only touch the following identifiers:FromNetwork, FromChannel, ToNetwork and ToChannel
Code
;###
;### TextPublisher v1
;### Author: Orel Eraki
;### Email: orel.eraki#gmail.com
;###
;### Usage:
;### - Pretty simple, just edit the identifier settings.
;### - For enable/disable change "TextPublisherEnable" identifier to 1 or 0
;### Settings
alias -l TextPublisherEnable return 1
alias -l TextPublisherFormat return &timestamp < &+ &nick &+ > &1-
alias -l TextPublisherMatchText return *text*
alias -l TextPublisherFromNetwork return Network1
alias -l TextPublisherFromChannel return #Channel1
alias -l TextPublisherToNetwork return Network2
alias -l TextPublisherToChannel return #Channel2
;### Functions
alias -l FindNetworkCid {
if ($1) {
var %i = 1, %n = $scon(0), %temp
while (%i <= %n) {
if ($scon(%i).status == connected && $scon(%i).network == $1) {
return $scon(%i).cid
}
inc %i
}
}
return
}
;### Events
on *:text:$($TextPublisherMatchText):$($TextPublisherFromChannel): {
if ($TextPublisherEnable && $network == $TextPublisherFromNetwork) {
var %networkId = $FindNetworkCid($TextPublisherToNetwork)
if (%networkId) {
scid -t1 %networkId if ($TextPublisherToChannel ischan) { msg $TextPublisherToChannel $eval($replace($TextPublisherFormat, &, $chr(36)), 2) }
}
}
}
This might help, Its taken from my Nick Mention and will work with any word you want. It comes up in the room you are in highlighted and also opens a new window and records what/who and time it was said. It may lead you in the direction you are looking for if it is not exactly what you are looking for..
;; Word mention ;;
on *:START: {
window -De #WordMention
echo #WordMention Your word mentioned and what was said goes here
}
on *:text:*:#:{
if (# == $active) halt
if (%me isin $strip($1-)) || ($me isin $strip($1-)) {
if (%mention. [ $+ [ $nick ] ] == $true) halt
echo -a 2,4 # $nick said : $1-
echo #WordMention =======================================
echo #WordMention 0,4 $+ $timestamp $nick said your word at $asctime(h:nn:sstt) in #
echo #WordMention $nick said: $1-
echo #WordMention =======================================
set -u10 %mention. [ $+ [ $nick ] ] $true
}
}
menu channel {
.Word mention ( $+ %mynick $+ )
..Set My word $iif(%me == $null,(no word set),( $+ %me $+ )):/set %me $$?="Enter word eg = word to watch for" | echo -a %me Set
..$iif(%myword == on,$style(2),$style(0)) On:/set %mynick on
..$iif(%myword == off,$style(2),$style(0)) Off:/set %mynick off
}

mIRC Script snippet misfirigin

Whenever somebody just types ! point the snippet runs through all of its commands for some reason I'm trying to find what causes this to happen, so far I cannot find the issue in the code
alias -l sd { return " $+ $scriptdir $+ $$1 $+ " }
on $*:text:/^!(monday|tuesday|wednesday|thursday|friday|saturday|sunday|website|food|touchy|sakura|Bass|bacon|snickers|bot|quiz|quizrules|NYE|NYD|stop|dance|Leta|back|sways|ladies|enters|choice|lounge|hiphop|fault|country|piano|rocks|diva|diva1|hello|sassy|hips|bounces|woot|kiss|pops|wiggle|greets|gotit|phone|next|cheeky|dj|xmas|here|guitar|twist|dj1|facebook|cheeky1|jig|birthday|thanks|chacha|moves|fleshies|aerial|drinks|heifer|dances|tap|chacha1|jam|hairbrush|hairbrush1|hairbrush2|reggae|lmfao|accept|hairbrush3|touch|no|music|tinbot|buffering|fleshie1|brat|2step|twirls|vote|whistle|hohey|scripted|botgurl|shows|phone1|laughs|me|crazy|shares|rani|takes|hour|mj|elvis|profiles|song|sweet|brightie|fire|passenger|lr|)$/Si:#:{
if (!%f) { inc -u6 %f
if ($isfile($sd(timetable.txt))) { .play $+(-t,$regml(1)) # $sd(timetable.txt) 50 }
else { msg # Either timetable.txt doesn't exist or the txt file name doesn't match! }
}
}
menu * {
Ping-Pong:$iif(%pp,pingpongoff,pingpongon)
Anti-Idle:$iif(%antiidle,antioff,antion)
}
on 1:ping: { $iif(%pp,raw pong $1 wannaplaypingpong,) }
on 1:pong: { $iif(%pp,raw ping $1 wannaplaypingpong,) }
alias pingpongoff { unset %pp | echo -a Ping-Pong has been disabled. }
alias pingpongon { set %pp on | echo -a Ping-Pong has been enabled. }
alias antioff { timeridle off | unset %antiidle | echo -a Anti-Idle has been disabled. }
alias antion { .timeridle 0 120 scid -atM1 antiidle | set %antiidle on | echo -a Anti-Idle has been enabled. }
alias antiidle { .msg $status $me }
raw 401:*: {
if (connected isin $1-) && (%antiidle) { echo -s ***** SassIRC Anti-Idle | halt }
}
}
}
You have an error at the end of your regex.
...fire|passenger|lr|)$..
Which contain redundant last pipe |, remove it from the end and it will solve the problem.