Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if cmd=="bgtime" and self.getAccess(user) >=4 and len(args) > 0:
- args=args.lower()
- if len(args.split(" ", -1)) != 1:
- return
- if len(args) == 1:
- f_args, s_args = args, args
- elif len(args) > 1:
- f_args, s_args = args[0], args[1]
- def getBgtime(args):
- expired = True
- url = ("http://st.chatango.com/profileimg/" + f_args + "/" + s_args + "/" + args + "/mod1.xml")
- f = urlreq.urlopen(url)
- data = f.read().decode("utf-8")
- e = ET.XML(data)
- bg = e.findtext("d")
- bg = int(urlreq.unquote(bg))
- if bg - int(time.time()) < 0:
- total_seconds = int(time.time())-bg
- else:
- total_seconds = bg-int(time.time())
- expired = False
- # Helper vars:
- MINUTE = 60
- HOUR = MINUTE * 60
- DAY = HOUR * 24
- # Get the days, hours, etc:
- days = int( total_seconds / DAY )
- hours = int( ( total_seconds % DAY ) / HOUR )
- minutes = int( ( total_seconds % HOUR ) / MINUTE )
- seconds = int( total_seconds % MINUTE )
- # Build up the pretty string (like this: "N days, N hours, N minutes, N seconds")
- string = ""
- if days > 0 or days < 0:
- string += str(days) + " " + (days == 1 and "day" or "days" ) + ", "
- if len(string) > 0 or hours > 0:
- string += str(hours) + " " + (hours == 1 and "hour" or "hours" ) + ", "
- if len(string) > 0 or minutes > 0:
- string += str(minutes) + " " + (minutes == 1 and "minute" or "minutes" ) + ", "
- string += str(seconds) + " " + (seconds == 1 and "second" or "seconds" )
- if expired == True:
- return "expired: "+string
- elif expired == False:
- return "time is: "+string
- room.message("<font face=\"arial\" size=\"11\"><b>" + args.title() + "</b> BG " + getBgtime(args), True)
Advertisement
Add Comment
Please, Sign In to add comment