mIRC Home    About    Download    Register    News    Help

Print Thread
#256057 14/12/15 10:18 PM
Joined: Nov 2015
Posts: 14
L
Lopin Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Nov 2015
Posts: 14
Hey there
I would do a code to tell me my bot, records bans moderators has set the month, day or week.
I could be done?
a greeting

For exmaple.

!bans Kevin
mi bot_> Kevin set 340 bans

Last edited by Lopin; 14/12/15 10:21 PM.
Joined: Dec 2015
Posts: 148
Vogon poet
Offline
Vogon poet
Joined: Dec 2015
Posts: 148
There's a tiny chance I'm about to get sick, it's the middle of the night and I haven't slept much, but this should work:

Code:
on *:join:#:tokenize 32 $+(#,@,$network) | if ($nick == $me) && (!$hget($1)) { hmake $1 | hload -i $1 Bans.db $1 }

on *:part:#:if ($nick == $me) savebans $+(#,@,$network) 1

on *:kick:#:if ($knick == $me) savebans $+(#,@,$network) 1

alias -l savebans if ($hget($1)) { hsave -i $1 Bans.db $1 | if ($2) hfree $1 }

on *:disconnect:var %x = 1 | while ($chan(%x)) { savebans $+($v1,@,$network) 1 | inc %x }

on *:ban:#: {
  var %h = $+(#,@,$network),%c $ctime($date 00:00:00)
  while ($asctime(%c,dddd) != monday) dec %c 86400
  tokenize 32 $hget(%h,$nick)
  hadd %h $nick $calc(1+$1) $iif($2 == $asctime(yyyy-mm),$2 $calc(1+$3),$v2 1) $iif($4 == %c,$4 $calc(1+$5),%c 1) $iif($6 == $asctime(yyyy-mm-dd),$6 $calc(1+$7),$v2 1)
  ;1=total bans, 2=yyyy-mm, 3=monthly bans, 4=last monday ctime, 5=weekly bans, 6=yyyy-mm-dd & 7=daily bans

  ;Remove the ";" character from below, if you want it to save the record each time its updated. (300 = 5 minute delay, so it's not constantly writing on the HDD/SSD.)
  ;.timersavebans $+ %h 1 300 savebans %h
}

on *:text:!bans*:#: {
  if ($2 ischan) tokenize 32 $2-3 $hget($+($2,@,$network),$3)
  else tokenize 32 # $2 $hget($+(#,@,$network),$2)
  if ($3) {
    var %c = $ctime($date 00:00:00)
    while ($asctime(%c,dddd) != monday) dec %c 86400
    notice $nick $2 has banned $iif($8 == $asctime(yyyy-mm-dd),$bytes($9,b) $users($9),0 users) today, $iif($6 == %c,$bytes($7,b) $users($7),0 users) this week, $iif($4 == $asctime(yyyy-mm),$bytes($5,b) $users($5),0 users) this month and $bytes($3,b) $users($3) overall on $1 $+ .
  }
  elseif ($2) notice $nick Either I have no idea who $2 is, or they haven't set any bans on $1 $+ .
  else notice $nick Usage: !bans [CHANNEL] <NICK>
}

alias -l users if ($1 == 1) return user | return users

It works on all channels your bot joins. If you want to limit it, define the channel(s) for the events.

It saves the records in "Bans.db" file, and the records are saved when the bot disconnects, leaves the channel or gets kicked from it, so if mIRC crashes or something, it'll lose all the records since the last save. There's a commented timer on the ban event that you can uncomment if you want it to save it after the records are updated.

By default the week starts on monday, if you want to change it, change the "monday" on the while loop in the ban and text event to whichever day you want.

To get it to work: just put it in the remote tab (preferably new file) and rejoin the channel(s).

Last edited by Dazuz; 15/12/15 05:35 AM. Reason: Bug fix.
Joined: Nov 2015
Posts: 14
L
Lopin Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Nov 2015
Posts: 14
thanks you :-)

Joined: Dec 2015
Posts: 148
Vogon poet
Offline
Vogon poet
Joined: Dec 2015
Posts: 148
May have noticed a tiny problem with it. It wasn't checking if it was the bot who joined/left the channel, so here's a fixed version:

Code:
on *:join:#:tokenize 32 $+(#,@,$network) | if ($nick == $me) && (!$hget($1)) { hmake $1 | hload -i $1 Bans.db $1 }

on *:part:#:if ($nick == $me) savebans $+(#,@,$network) 1

on *:kick:#:if ($knick == $me) savebans $+(#,@,$network) 1

alias -l savebans if ($hget($1)) { hsave -i $1 Bans.db $1 | if ($2) hfree $1 }

on *:disconnect:var %x = 1 | while ($chan(%x)) { savebans $+($v1,@,$network) 1 | inc %x }

on *:ban:#: {
  var %h = $+(#,@,$network),%c $ctime($date 00:00:00)
  while ($asctime(%c,dddd) != monday) dec %c 86400
  tokenize 32 $hget(%h,$nick)
  hadd %h $nick $calc(1+$1) $iif($2 == $asctime(yyyy-mm),$2 $calc(1+$3),$v2 1) $iif($4 == %c,$4 $calc(1+$5),%c 1) $iif($6 == $asctime(yyyy-mm-dd),$6 $calc(1+$7),$v2 1)
  ;1=total bans, 2=yyyy-mm, 3=monthly bans, 4=last monday ctime, 5=weekly bans, 6=yyyy-mm-dd & 7=daily bans

  ;Remove the ";" character from below, if you want it to save the record each time its updated. (300 = 5 minute delay, so it's not constantly writing on the HDD/SSD.)
  ;.timersavebans $+ %h 1 300 savebans %h
}

on *:text:!bans*:#: {
  if ($2 ischan) tokenize 32 $2-3 $hget($+($2,@,$network),$3)
  else tokenize 32 # $2 $hget($+(#,@,$network),$2)
  if ($3) {
    var %c = $ctime($date 00:00:00)
    while ($asctime(%c,dddd) != monday) dec %c 86400
    notice $nick $2 has banned $iif($8 == $asctime(yyyy-mm-dd),$bytes($9,b) $users($9),0 users) today, $iif($6 == %c,$bytes($7,b) $users($7),0 users) this week, $iif($4 == $asctime(yyyy-mm),$bytes($5,b) $users($5),0 users) this month and $bytes($3,b) $users($3) overall on $1 $+ .
  }
  elseif ($2) notice $nick Either I have no idea who $2 is, or they haven't set any bans on $1 $+ .
  else notice $nick Usage: !bans [CHANNEL] <NICK>
}

alias -l users if ($1 == 1) return user | return users


It's surprisingly painful to do this with a phone.

Joined: May 2015
Posts: 249
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
I wonder, isnt it a twitch-related topic or not..?


Dont give a fish - teach to fish!
Joined: Nov 2015
Posts: 14
L
Lopin Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Nov 2015
Posts: 14
thanks its works very well :))))


Link Copied to Clipboard