Infoline

By Get_A_Fix on Sep 14, 2010

A basic script to set, check, del an infoline for a channel. This is channel specific, I didn't add a global option. There was a reason for that :)

Commands are:
!infoline add text to add for infoline
to add a new infoline, or replace an old one.
NOTE: text for infoline is restricted to 120 characters. Exceeding this limit will cut the text off.

!infoline del
to remove set infoline.

!infoline show
to show current infoline.

!greet on|off
to enable|disable the greet setting for the channel.

# $Id: infoline.tcl,v1 25/01/2013 02:29:42am GMT +12 (NZST) istok@IRCSpeed.org Exp $
# Set global trigger here
set triga "!"

# Set global flags allowed to use infoline and greet commands.
set globflags o

# Set channel flags allowed to use infoline command.
set chanflags vo

# Set channel flags allowed to use the greet command.
set chanflags2 m

# ----- NOTHING ELSE TO SET! -----
proc getTrigger { } {
  global triga
  return $triga
}

bind pub - ${triga}infoline info:line

proc info:line {nick uhost hand chan arg} {

  global globflags chanflags
  if {![matchattr [nick2hand $nick] $globflags|$chanflags $chan]} {return}

  if {([lindex [split $arg] 0] == "") && (![regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]infoline add whatever text you want - [getTrigger]infoline del - [getTrigger]infoline show"; return}

  if {([lindex [split $arg] 0] == "") && ([regexp c [getchanmode $chan]])} {putquick "PRIVMSG $chan :ERROR: Incorrect Parameters. SYNTAX: [getTrigger]infoline add whatever text you want - [getTrigger]infoline del - [getTrigger]infoline show"; return}

  if {[lindex [split $arg] 0] == "add"} {

    set infotext [join [lrange [split $arg] 1 end]]

    setchaninfo "[nick2hand $nick]" "$chan" "$infotext"

    if {![regexp c [getchanmode $chan]] && ![channel get $chan greet]} {putquick "PRIVMSG $chan :InfoLine for \002$nick\002 now set to \002$infotext\002"; channel set $chan +greet ; return}

    if {[regexp c [getchanmode $chan]] && ![channel get $chan greet]} {putquick "PRIVMSG $chan :InfoLine for $nick now set to $infotext"; channel set $chan +greet ; return}

    if {![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :InfoLine for \002$nick\002 now set to \002$infotext\002"; return}

    if {[regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :InfoLine for $nick now set to $infotext"; return}

  }

  if {[lindex [split $arg] 0] == "del"} {

    if {[getchaninfo [nick2hand $nick] $chan] == ""} {putquick "PRIVMSG $chan :You currently have no infoline set for $chan"; return}

    setchaninfo "[nick2hand $nick]" "$chan" "none"

    if {![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :InfoLine for \002$nick\002 has now been \002removed\002."; return}

    if {[regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :InfoLine for $nick has now been removed."; return}

  }

  if {[lindex [split $arg] 0] == "show"} {

    set showtxt [getchaninfo [nick2hand $nick] $chan]

    if {$showtxt == ""} {putquick "PRIVMSG $chan :You currently have no infoline set for $chan"; return}

    if {![regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :InfoLine for \002$nick\002 currently set to: \002$showtxt\002"; return}

    if {[regexp c [getchanmode $chan]]} {putquick "PRIVMSG $chan :InfoLine for $nick currently set to: $showtxt"; return}

  }

}

bind pub - ${triga}greet greet:pub

proc greet:pub {nick uhost hand chan arg} {

  global globflags chanflags2
  if {[matchattr [nick2hand $nick] $globflags|$chanflags2 $chan]} {

    if {[lindex [split $arg] 0] == ""} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrigger]greet on|off"; return}

    if {[lindex [split $arg] 0] == "on"} {

      if {[channel get $chan greet]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already enabled."; return}

      channel set $chan +greet

      puthelp "PRIVMSG $chan :Enabled Greets for $chan"

    }

    if {[lindex [split $arg] 0] == "off"} {

      if {![channel get $chan greet]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already disabled."; return}

      channel set $chan -greet

      puthelp "PRIVMSG $chan :Disabled Greets for $chan"

    }

  }

}

putlog "InfoLine Module Loaded! - istok@IRCSpeed.org"

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.