Advertisement
Guest User

Prefix Tutorial

a guest
Sep 2nd, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1. import ch #example import    
  2. prefix = "/" # this is where you choose the prefix, put this below imports
  3.        
  4.  
  5.  
  6.  
  7.  
  8.          def onMessage(self, room, user, message):#keep everything here the same, this goes where your old onMessage goes.
  9.                 # make global
  10.                 global activated
  11.                 global lockdown
  12.                 ## print to console
  13.  
  14.                 #split message into command and args
  15.                 data = message.body.split(" ", 1)
  16.                 if len(data) > 1:
  17.                         cmd, args = data[0], data[1] # if command and args
  18.                 else:
  19.                         cmd, args  = data[0], ""# if command and no args
  20.                
  21.                
  22.                 # put this above the command list
  23.                 if len(cmd) > 0:
  24.                         if cmd[0] == prefix:
  25.                                 used_prefix = True
  26.                                 cmd = cmd[1:]
  27.                         else: used_prefix = False
  28.                 else: return
  29.                
  30.                 # I am putting this here to show you what a basic command is like using this prefix system
  31.                 elif used_prefix and cmd == "newprefix":
  32.                         room.message("worked")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement