egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

BIND PUB and BIND MSGM args

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Sun May 03, 2015 6:48 pm    Post subject: BIND PUB and BIND MSGM args Reply with quote

I have a code that lists the help commands the bot.
To execute the command channel (for full list commands) is:
Quote:
!commands

To execute the command channel (for full particular command) is:
Quote:
!commands <command>

For private messages is (for full list commands) :
Quote:
commands

But, not works for messages:
Quote:
commands <command>


How do you, for boT interpret the event MSGM arguments after the command text?
Just accept me the command without arguments, that is, the command that displays a list of available commands of the bot, but does not allow me to show support for a particular command, running the SWITCH command .

Example of part code (the commands list is very long to put it all):
Code:
##default prefix !, You can replace it##
set prefix "!"
set canal_radio #chann1
set canal_djs #chann2
set canal_admin #chann3

bind pub oa|n [string trim $prefix]commands pub:help
bind msgm oa|n commands pub:help

proc pub:help {nick uhost hand chan args} {
   global botnick prefix canal_admin canal_djs
   set args [split [cleanarg $args]]
   if {(![matchattr $nick a|n]) && ([matchattr $nick +o])} {
   if {[llength $args]<1} {
putmsg $nick "Commands list for Administrators"
putmsg $nick [encoding convertfrom utf-8 " - [string trim $prefix]comm1 - task xxx perform "]
putmsg $nick [encoding convertfrom utf-8 " - [string trim $prefix]comm2 - task xxx perform "]
putmsg $nick [encoding convertfrom utf-8 " - [string trim $prefix]comm3 - task xxx perform "]
### ....More help command.............###
} else {
if {[string index $args 0] == "$prefix"} { set args [string trimleft $args $prefix] }
set lines [comm1 comm2 comm3]
if {([lsearch -exact [string tolower $lines] $args] == -1)} { putmsg $chan "$nick Sorry I have no help for that command. \002$args.";return }    
   switch [lindex $args 0] {
   "comm1" {
putmsg $nick "\002\0036<===--- !comm1 ---===>\0036\002"
putmsg $nick "Usage: [string trim $prefix]comm1 <nick Dj>"
putmsg $nick "Usage channels: $canal_admin and $canal_djs"
putmsg $nick [encoding convertfrom utf-8 "Function: xxxxxxx"]
putmsg $nick "\002\0036<===--- End help comannd !comm1 ---===>\0036\002"
   }
"comm2" {
putmsg $nick "\002\0036<===--- !comm2 ---===>\0036\002"
putmsg $nick "Usage: [string trim $prefix]comm2 <#channel>"
putmsg $nick "Usage channels: $canal_admin and $canal_djs"
putmsg $nick [encoding convertfrom utf-8 "Function: xxxxxxx"]
putmsg $nick "\002\0036<===--- End help comannd !comm2 ---===>\0036\002"
   }
"comm3" {
putmsg $nick "\002\0036<===--- !comm3 ---===>\0036\002"
putmsg $nick "Usage: [string trim $prefix]comm3 <nick>"
putmsg $nick "Usage channels: $canal_admin and"
putmsg $nick [encoding convertfrom utf-8 "Function: xxxxxxx"]
putmsg $nick "\002\0036<===--- End help comannd !comm3 ---===>\0036\002"
   }
}
}
} else {
if {[llength $args]<1} {
putmsg $nick "Commands list for Roots"
putmsg $nick [encoding convertfrom utf-8 " - [string trim $prefix]comm1 - task xxx perform "]
putmsg $nick [encoding convertfrom utf-8 " - [string trim $prefix]comm2 - task xxx perform "]
putmsg $nick [encoding convertfrom utf-8 " - [string trim $prefix]comm3 - task xxx perform "]
### ....More help command.............###
} else {
if {[string index $args 0] == "$prefix"} { set args [string trimleft $args $prefix] }
set lines [comm1 comm2 comm3]
if {([lsearch -exact [string tolower $lines] $args] == -1)} { putmsg $chan "$nick Sorry I have no help for that command. \002$args.";return }    
   switch [lindex $args 0] {
   "comm1" {
putmsg $nick "\002\0036<===--- !comm1 ---===>\0036\002"
putmsg $nick "Usage: [string trim $prefix]comm1 <nick Dj>"
putmsg $nick "Usage channels: $canal_admin and $canal_djs"
putmsg $nick [encoding convertfrom utf-8 "Function: xxxxxxx"]
putmsg $nick "\002\0036<===--- End help comannd !comm1 ---===>\0036\002"
   }
"comm2" {
putmsg $nick "\002\0036<===--- !comm2 ---===>\0036\002"
putmsg $nick "Usage: [string trim $prefix]comm2 <#channel>"
putmsg $nick "Usage channels: $canal_admin and $canal_djs"
putmsg $nick [encoding convertfrom utf-8 "Function: xxxxxxx"]
putmsg $nick "\002\0036<===--- End help comannd !comm2 ---===>\0036\002"
   }
"comm3" {
putmsg $nick "\002\0036<===--- !comm3 ---===>\0036\002"
putmsg $nick "Usage: [string trim $prefix]comm3 <nick>"
putmsg $nick "Usage channels: $canal_admin and"
putmsg $nick [encoding convertfrom utf-8 "Function: xxxxxxx"]
putmsg $nick "\002\0036<===--- End help comannd !comm3 ---===>\0036\002"
   }
}
}

}
}

proc cleanarg {arg} {
 set temp ""
   for {set i 0} {$i < [string length $arg]} {incr i} {
  set char [string index $arg $i]
  if {($char != "\12") && ($char != "\15")} {
   append temp $char
  }
 }

 set temp [string trimright $temp "\}"]

 set temp [string trimleft $temp "\{"]
   return $temp
}


EDIT: Add to end processes that I forgot to put code before.
EDIT2: Translate variable name 'prefijo' to English 'prefix'.
_________________
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber