Purple exclamation mark.svg Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.

Red exclamation mark.svg UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.

Python:BotSottile/admin.py

From Botwiki
Jump to: navigation, search
#!/usr/bin/env python
"""
admin.py - Manage bot
Author: FiloSottile@it.wiki
About
"""
 
import random, re, os
 
def f_join(self, origin, match, args): 
   #:ChanServ!ChanServ@services. MODE #wikizionario +o Filnik
   term = '#' + match.group(3)
   for i in [self.config.owner, self.config.alternate] + self.config.closers:
      if origin.nick == i:
            access = True
   if access:
      self.callOP = 'join'
      self.opdata = term
      self.write(('WHOIS', origin.nick))
   else:
      self.notice(origin.nick, "%s: Only my owner can make join me on other channels." % origin.nick)   
f_join.rule = r"(?i)^\.j(oin)?(\: | )\#(.*?)$"
 
def f_nickname(self, origin, match, args): 
   #reply2 = random.choice(['lol', ':)', ':D', 'rotfl', 'XD', ':P'])
   term = match.group(1)
   if origin.nick.lower() == self.config.owner.lower():
      self.callOP = 'nick'
      self.opdata = term
      self.write(('WHOIS', origin.nick))
   else:
      self.notice(origin.nick, "%s: Only my owner can change my nickname." % origin.nick)
f_nickname.rule = (['nick'], r"(.*)")
 
def f_action(self, origin, match, args): 
   term = match.group(1)
   if origin.nick == self.config.owner:
      self.msg(origin.sender, '\x01ACTION %s\x01' % term)
   else:
      self.notice(origin.nick, "%s: Only my owner can do that." % origin.nick)
f_action.rule = (['act', 'action'], r"(.*)")
 
def f_actto(self, origin, match, args): 
   term = match.group(3)
   if origin.nick == self.config.owner:
      self.msg('#' + match.group(2), '\x01ACTION %s\x01' % (term))
   else:
      self.notice(origin.nick, '\x01ACTION %s\x01' % (term))      
f_actto.rule = r"(?i)^\.actto(\: | )\#(.*?) (.*?)$"
 
def f_sayto(self, origin, match, args): 
   term = match.group(3)
   if origin.nick == self.config.owner:
      self.msg('#' + match.group(2), '%s' % (term))
   else:
      self.notice(origin.nick, '%s' % (term))      
f_sayto.rule = r"(?i)^\.sayto(\: | )\#(.*?) (.*?)$"
 
def f_say(self, origin, match, args): 
   #reply2 = random.choice(['lol', ':)', ':D', 'rotfl', 'XD', ':P'])
   term = match.group(1)
   if origin.nick == self.config.owner:
      self.msg(origin.sender, '%s' % term)
   else:
      self.notice(origin.nick, '%s' % term)
f_say.rule = (['say'], r"(.*)")
 
def f_part(self, origin, match, args): 
   #reply2 = random.choice(['lol', ':)', ':D', 'rotfl', 'XD', ':P'])
   term = match.group(1)
   access = False
   self.callOP = 'part'
   for i in [self.config.owner, self.config.alternate] + self.config.closers: 
      if origin.nick == i:
            access = True
   if term != '':
      if access == True:
         self.write(('WHOIS', origin.nick))
         self.opdata = term
      else:
         self.notice(origin.nick, "%s: Only my owner can do this operation." % origin.nick)
   else:
      if access == True:
         self.write(('WHOIS', origin.nick))
         self.opdata = origin.sender
      else:
         self.notice(origin.nick, "%s: Only my owner can do this operation." % origin.nick)     
f_part.rule = (['part'], r"(.*)")
 
def f_quit(self, origin, match, args): 
   #reply2 = random.choice(['lol', ':)', ':D', 'rotfl', 'XD', ':P'])
   term = match.group(1)
   access = False
   self.callOP = 'quit'
   for i in [self.config.owner, self.config.alternate] + self.config.closers:
      if origin.nick == i:
            access = True
   if term != '':
      if access == True:
         self.write(('WHOIS', origin.nick))
         self.opdata = term
      else:
         self.notice(origin.nick, "%s: Only my owner can do this operation." % origin.nick)
   else:
      if access == True:
         self.write(('WHOIS', origin.nick))
         self.opdata = ''
      else:
         self.notice(origin.nick, "%s: Only my owner can do this operation." % origin.nick)     
f_quit.rule = (['quit'], r"(.*)")
 
def f_register(self, origin, match, args): 
   #:ChanServ!ChanServ@services. MODE #botolatori +o Fabexplosive
   if origin.nick == self.config.owner:
      self.msg('NickServ', 'IDENTIFY %s' % match.group(1))
      self.msg(origin.nick, 'Identified!')
f_register.rule = (['register', 'identify'], r"(.*)")
 
def f_ghost(self, origin, match, args):
   term = match.group(3)
   ghost = False   
   for i in ['', ' ', '  ']:
      if term == i:
         ghost = True
   if ghost == True:
      self.msg(origin.nick, "You haven't specified the password, retry.") 
   else:
      self.msg('NickServ', 'ghost ' + term)
      self.msg(self.config.owner, 'ghost ' + term) 
f_ghost.rule = r"(?i)^(\.|\!)ghost(me)? ?(.*?)$"
 
def f_eval(self, origin, match, args): 
   #reply2 = random.choice(['lol', ':)', ':D', 'rotfl', 'XD', ':P'])
   term = match.group(1)
   if origin.nick.lower() == self.config.owner.lower():
      self.callOP = 'eval'
      self.opdata = (term, origin.nick)
      self.write(('WHOIS', origin.nick))
   else:
      self.notice(origin.nick, "%s: Only my owner can do that." % origin.nick)
f_eval.rule = (['eval'], r"(.*)")
 
#
Personal tools
Share