Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ON *:START: { load_db }
- ON *:JOIN:#: {
- if ($nick !== $me) { return }
- var %h = $hget(AUTOTALK_ $+ $network,$chan)
- if (%h) { .timer[AUTOTALK_ $+ $network $+ _ $+ $chan $+ _NOW] 0 %h autotalk $network $chan }
- }
- ON *:PART:#: {
- if ($nick !== $me) { return }
- var %h = $hget(AUTOTALK_ $+ $network,$chan)
- if (%h) { .timer[AUTOTALK_ $+ $network $+ _ $+ $chan $+ _NOW] off }
- }
- ON *:KICK:#: {
- if ($knick !== $me) { return }
- var %h = $hget(AUTOTALK_ $+ $network,$chan)
- if (%h) { .timer[AUTOTALK_ $+ $network $+ _ $+ $chan $+ _NOW] off }
- }
- ON *:TEXT:*:?: {
- if ($1 == !autotalk) {
- var %o = add del list
- if (!$2) { msg $nick ( $+ $nick $+ ): Error, Enter one of these values $qt(%o) to proceed! | return }
- if (!$istok(%o,$2,32)) { msg $nick ( $+ $nick $+ ): Error, Enter one valid option from $qt(%o) options! | return }
- if ($2 == add) {
- var %f = autotalk.db
- if (!$3) { msg $nick ( $+ $nick $+ ): Error, Enter a network name! | return }
- if (!$4) { msg $nick ( $+ $nick $+ ): Error, Enter a channel name! | return }
- if ($left($4,1) !== $chr(35)) { msg $nick ( $+ $nick $+ ): Error, Enter a valid channel name! | return }
- var %h = $hget(AUTOTALK_ $+ $3,$4)
- if (%h) { msg $nick ( $+ $nick $+ ): Error, $4 channel is already exists on $3 network! | return }
- if ($5) && ($5 isnum) { var %n = $5 }
- else { var %n = $rands(900,1200) }
- hadd -m AUTOTALK_ $+ $3 $4 %n
- save_db
- .timer[AUTOTALK_ $+ $3 $+ _ $+ $4 $+ _NOW] 0 %n autotalk $3 $4
- msg $nick ( $+ $nick $+ ): Added the $4 channel on $3 network list with %n random autotalk seconds.
- }
- if ($2 == del) {
- var %f = autotalk.db
- if (!$3) { msg $nick ( $+ $nick $+ ): Error, Enter a network name! | return }
- if (!$4) { msg $nick ( $+ $nick $+ ): Error, Enter a channel name! | return }
- if ($left($4,1) !== $chr(35)) { msg $nick ( $+ $nick $+ ): Error, Enter a valid channel name! | return }
- var %h = $hget(AUTOTALK_ $+ $3,$4)
- if (!%h) { msg $nick ( $+ $nick $+ ): Error, $4 channel does NOT exists on $3 network! | return }
- hdel AUTOTALK_ $+ $3 $4
- if (!$hget(AUTOTALK_ $+ $3,0).item) { hfree AUTOTALK_ $+ $3 }
- save_db
- .timer[AUTOTALK_ $+ $3 $+ _ $+ $4 $+ _NOW] off
- msg $nick ( $+ $nick $+ ): Removed the $4 channel from $3 network list with %h random autotalk seconds.
- }
- if ($2 == list) {
- var %t = $hget(0)
- var %i = 1
- while (%i <= %t) {
- var %h = $hget(%i)
- var %m = $hget(%h,0).item
- if (!%h) || (!%m) || (AUTOTALK_* !iswm %h) { goto list_next }
- var %z = 1
- while (%z <= %m) {
- var %c = $hget(%h,%z).item
- var %d = $hget(%h,%z).data
- if (%c) && (%d) { msg $nick ( $+ $nick $+ ): $gettok(%h,2-,95) - %c - %d }
- inc %z
- }
- :list_next
- inc %i
- }
- msg $nick ( $+ $nick $+ ): End of autotalk list.
- }
- }
- }
- alias load_db {
- ; /load_db
- var %f = autotalk.db
- var %t = $ini(%f,0)
- if (!%t) { return }
- var %i = 1
- while (%i <= %t) {
- var %n = $ini(%f,%i)
- var %m = $ini(%f,%n,0)
- if (!%n) || (!%m) { goto next }
- var %z = 1
- while (%z <= %m) {
- var %c = $ini(%f,%n,%z)
- var %v = $readini(%f,n,%n,%c)
- if (%c) && (%v) { hadd -m %n %c %v }
- inc %z
- }
- :next
- inc %i
- }
- }
- alias save_db {
- ; /save_db
- var %f = autotalk.db
- if ($isfile(%f)) { .remove $qt(%f) }
- var %t = $hget(0)
- var %i = 1
- while (%i <= %t) {
- var %h = $hget(%i)
- var %m = $hget(%h,0).item
- if (!%h) || (!%m) || (AUTOTALK_* !iswm %h) { goto next }
- var %z = 1
- while (%z <= %m) {
- var %c = $hget(%h,%z).item
- var %d = $hget(%h,%z).data
- if (%c) && (%d) { writeini -n $qt(%f) %h Channel_ $+ %c %d }
- inc %z
- }
- :next
- inc %i
- }
- }
- alias autotalk {
- ; /autotalk Network #Channel
- if (!$1) || (!$2) { return }
- var %f = msgrandom.txt
- var %r = $read(%f,n)
- if (!$file(%f)) { return }
- if (!$check_network_channel($1,$2)) { return }
- if (!%r) { return }
- var %cid = $get_network_cid($1)
- if (!%cid) { return }
- scid %cid
- msg $2 %r
- }
- alias -l check_network_channel {
- ; $check_network_channel(Network,#Channel)
- if (!$1) && (!$2) { return }
- var %t = $scon(0)
- var %i = 1
- while (%i <= %t) {
- var %n = $scon(%i).network
- var %u = $scon(%i).status
- var %d = $scon(%i).cid
- if ($1 == %n) && (%u == connected) && (%d) {
- scid %d
- if ($me ison $2) { return 1 }
- }
- inc %i
- }
- return 0
- }
- alias -l get_network_cid {
- ; $get_network_cid(Network)
- if (!$1) { return }
- var %t = $scon(0)
- var %i = 1
- while (%i <= %t) {
- var %n = $scon(%i).network
- var %d = $scon(%i).cid
- if ($1 == %n) && (%d) { return %d }
- inc %i
- }
- return 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement