1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
#cs Autore: Red Skull Mail: RedSkull[At]gmail[Dot]com Web: http://redskull92.wordpress.com Descrizione: Bot Irc in AutoIt By Red Skull Versione: 1.0 #ce #include <string.au3> #include <array.au3> Global Const $server="server",$porta=6668,$nick="SkullBot",$canale="#canale",$version="1.0",$padrone="nick" Global $tizzi[1] TCPStartup() Global $conn=TCPConnect(TCPNameToIP($server),$porta) TCPSend($conn,"NICK "&$nick&@CRLF) TCPSend($conn,"USER "&$nick&" 0 * :"&$nick&@CRLF) TCPSend($conn,"JOIN "&$canale&@CRLF) ;Saluta appena entra Rispondi(0,"Salve") While 1 $recv = TCPRecv($conn, 10000) $split=StringSplit($recv,@CRLF) For $i=0 To $split[0] $cerca=StringSplit($split[$i]," ") ;Risponde al PING If $cerca[1] = "PING" Then TCPSend($conn,"PONG "&$cerca[2]&@CRLF) If $cerca[1] = "" Then ContinueLoop If $cerca[0] <= 2 Then ContinueLoop Switch $cerca[2] Case "PRIVMSG" ;Prende user e messaggio Global $user=StringRegExp($cerca[1],":(.*?)!",3) Global $mex=StringRegExp($split[$i],":(.+?):(.+)",3) If StringCompare($cerca[3],$canale) <> 0 Then ;Se riceve una query Controlla(StringLower($mex[1]),$user[0],1) Else ;Se riceve un messaggio publico Controlla(StringLower($mex[1]),$user[0],0) EndIf Case "KICK" ;In caso il bot viene kickato Dim $text[7]=["Perchè ?","Fottiti","Fanculo","Muori","Fuck","GTFO"] TCPSend($conn,"JOIN "&$canale&@CRLF) $who=StringRegExp($cerca[1],":(.*?)!",3) Rispondi(0,$text[Random(0,6,1)]&" "&$who[0]) Case "QUIT" $tizzio=StringRegExp($cerca[1],":(.*?)!",3) _ArrayDelete($tizzi,$tizzio[0]) EndSwitch Next WEnd Func Rispondi($priv=0,$msg="") If $priv = 0 Then ;Public TCPSend($conn,"PRIVMSG "&$canale&" :"&$msg&@CRLF) Else ;Query TCPSend($conn,"PRIVMSG "&$user[0]&" :"&$msg&@CRLF) EndIf EndFunc Func Controlla($mex="",$utente="",$query=0) ;Saluta 1 sola volta per utente, a meno chè non quitti. $find=StringRegExp($mex,"(ciao|we!eccomi|salve|hola|giorno|sera|notte)",3) If @error = 0 And _ArraySearch($tizzi,$utente) = -1 Then Rispondi($query,"Ciao "&$utente&" ^^") _ArrayAdd($tizzi,$utente) EndIf ;Versione $find=StringRegExp($mex,"!!v",3) If @error = 0 Then Rispondi($query,"Versione SkullBot : "&$version) ;Uso $find=StringRegExp($mex,"!!usage",3) If @error = 0 Then If $utente = $padrone Then Rispondi(0,"SkullBot By Red Skull") Rispondi(0,"Versione:"&$version) Rispondi(0,"!!v - Mostra la versione") Rispondi(0,"!!author - Mostra l'autore") Rispondi(0,"!!quit - Termina il bot") Rispondi(0,"!!speak - Parla al posto tuo (Solo in query)") Rispondi(0,"!!upper - Trasforma una stringa in MAIUSCOLO") Rispondi(0,"!!reverse - Gira una stringa") Else Rispondi(0,"Solo il mio padrone può vedere come usarmi !") EndIf EndIf ;Autore $find=StringRegExp($mex,"!!author",3) If @error = 0 Then Rispondi(0,"Autore: Red Skull") Rispondi(0,"Mail: RedSkull92@gmail.com") Rispondi(0,"Sito: http://redskull92.wordpress.com") EndIf ;Uscita $find=StringRegExp($mex,"!!quit",3) If @error = 0 Then If $utente = $padrone Then Rispondi($query,"Bye !!") TCPSend($conn,"QUIT"&@CRLF) TCPShutdown() Exit Else Rispondi($query,"Solo il mio padrone può terminarmi!") EndIf EndIf ;Parla come il bot $find=StringRegExp($mex,"!!speak (.+)",3) If @error = 0 And $query=1 Then If $utente = $padrone Then Rispondi(0,$find[0]) Else Rispondi(0,"Solo il mio padrone può farmi parlare!") EndIf EndIf ;Trasforma una stringa in maiuscolo $find=StringRegExp($mex,"!!upper (.+)",3) If @error = 0 Then Rispondi($query,StringUpper($find[0])) ;Stampa la stringa al contrario $find=StringRegExp($mex,"!!reverse (.+)",3) If @error = 0 Then Rispondi($query,_StringReverse($find[0])) EndFunc ;By ;Red Skull |
SkullBot
By Red Skull