0rx

Chatango Bot Timeban Command

0rx
Jul 12th, 2014
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.19 KB | None | 0 0
  1.         elif cmd=="timeban"  and len(args)>0:
  2.           if room.getLevel(self.user) == 0:
  3.             room.message("I'm not modded.")
  4.             return
  5.           if room.getLevel(user) > 0:
  6.             try:
  7.               #split args into name , time
  8.               tname,timey=args.split(" ",1)
  9.               if pars(tname) == None:
  10.                     room.message("Who the fook is "+tname+" ??")
  11.                     return
  12.               tname = pars(tname)
  13.               #make time string into an int
  14.               if "-" in timey:
  15.                 room.message("Stop doing that. Please type a propper number.")
  16.                 return
  17.               timey=int(timey)
  18.               minute = 60
  19.               hour = minute * 60
  20.               day = hour * 24
  21.               days =  int(timey / day)
  22.               hours = int((timey % day) / hour)
  23.               minutes = int((timey % hour) / minute)
  24.               seconds = int(timey % minute)
  25.               string = ""
  26.               if days > 0:
  27.                 string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
  28.               if len(string) > 0 or hours > 0:
  29.                 string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
  30.               if len(string) > 0 or minutes > 0:
  31.                 string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
  32.               string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
  33.               #banuser name
  34.               room.banUser(ch.User(tname.lower()))
  35.               #print message
  36.               room.message(tname+" will be banned for : "+string+".")
  37.               #set the unban command to the timeout time
  38.               self.setTimeout(int(timey),room.unban,ch.User(tname.lower()))
  39.               #set the message timeout to the bantime + 3 more seconds(just cuz)
  40.               self.setTimeout(int(timey+1),room.message,tname.title()+" is unbanned after "+string+" period of darkness")
  41.             except:
  42.               #if there is an error , print the error code in the chatroom
  43.               room.message("[ERR]Expectation Failed!!")
  44.           else:
  45.             room.message("Only room Owner and Moderators permitted.")
Advertisement
Add Comment
Please, Sign In to add comment