def onMessage(self, room, user, message): if user == self.user: return if not message.body.strip(): return msgdata = message.body.strip().split(" ", 1) PREFIX = config.User(user.name).prefix if len(msgdata) == 2: cmd, args = msgdata else: cmd, args = msgdata[0], "" if cmd == PREFIX: msgdata = args.split(" ", 1) if len(msgdata) == 2: cmd, args = msgdata else: cmd, args = msgdata[0], "" elif (cmd.lower() == "@" + self.user.name.replace("#", "").replace("!", "")): msgdata = args.split(" ", 1) if len(msgdata) == 2: cmd, args = msgdata else: cmd, args = msgdata[0], "" elif cmd[:len(PREFIX)] == PREFIX: cmd = cmd[len(PREFIX):] else: return cmd = cmd.lower().strip() if cmd not in config.cmds: return try: exec(config.cmds[cmd], locals()) except: exc_type, exc_value, exc_traceback = sys.exc_info() msg = "\n\n" msg += ("<b>{0}</b>: <f x{1}{2}=\"8\">" "{4}<f x{1}{2}=\"{3}\">\n").format( exc_type.__name__, str(self.user.fontSize).rjust(2, "0"), self.user.fontColor, self.user.fontFace, html.escape(str(exc_value))) for frame in traceback.extract_tb(exc_traceback): filename = frame.filename if filename.startswith(config.CWD): filename = "." + filename[len(config.CWD):] msg += "File <i>{}</i> line {}: {}\n".format( html.escape(filename), frame.lineno, html.escape(frame.name)) room.message(msg, html=True) traceback.print_exc()
def __init__(self): checkjumpdb() user = config.User() window = self.window = tk.Toplevel() global win win = window window.title("JumpWizard") window.wm_iconbitmap('graphics/jvdb.ico') #window.wm_iconbitmap('jwicon.ico') window.title("JumpVisual Photographer Coverage Wizard") window.resizable(width=False, height=False) baseimage = self.baseimage = tk.PhotoImage(file='graphics/jump.pbm') njimage = self.njimage = tk.PhotoImage(file='graphics/s_nj.pbm') # nyimage = tk.PhotoImage(file='graphics/s_ny.pbm') # ctimage = tk.PhotoImage(file='graphics/s_ct.pbm') leftframe = tk.Frame(window, width=600) leftframe.grid(row=0, column=0, sticky='news', rowspan=4) sidebar = tk.Label(leftframe, image=baseimage) sidebar.image = baseimage sidebar.grid(row=0, column=0, sticky='ns') # current_frame = frames[i](win, user, i, padx=30, pady=30, width=400) # current_frame.grid(row=0,column=1) #styling window.grid_propagate(True) leftframe.rowconfigure(0, weight=1) leftframe.columnconfigure(0, weight=0) window.rowconfigure(1, weight=1) frames = [infoframe.InfoFrame] limit = len(frames) def drawframe(user, i): """draws parent frame""" config.current_frame = infoframe.InfoFrame(win, user, padx=30, pady=30, width=400) # current_frame = frames[i](win, user, i, frames, padx=30, pady=30, width=400) # if type(config.current_frame) == NJCounties: # sidebar.image = njimage # elif config.current_frame == NYCounties: # sidebar.image = nyimage # elif config.current_frame == CTCounties: # sidebar.image = ctimage # else: # print("config.current_frame is not NJ, Ny, or CT") # sidebar.image = baseimage # sidebar.grid(row=0, column=0, sticky='ns') config.current_frame.grid(row=0, column=1) drawframe(user, i)
def choose_sport(message): try: chat_id = message.chat.id sport = message.text if sport == u'Футбол': user = config.User(sport) user.chat_id = chat_id config.user_dict[chat_id] = user markup = types.ReplyKeyboardMarkup(one_time_keyboard=True, resize_keyboard=True) markup.add('1 тайм', '2 тайм') msg = bot.reply_to(message, 'Выберите тайм:', reply_markup=markup) bot.register_next_step_handler(msg, choose_time) else: raise Exception() except Exception: bot.reply_to(message, 'ooops')
import config clang = "en" if user.name[0] in "#!" else config.User(user.name).lang if user.name in config.owners: cmds = config.cmds.keys() else: cmds = [x for x in config.cmds.keys() if x[0] != "_"] msg = config.get_lang(clang, "available_commands") msg = msg.format(", ".join(sorted(cmds))) room.message(msg, True)
import config cuser = config.User(user.name) msg = config.get_lang(cuser.lang, "hello").format(user.capser) room.message(msg)
import config import random import time import math import html import ch args = args.split() cuser = None if user.name[0] in "#!" else config.User(user.name) lang = cuser.lang if cuser else "en" nan, inf = math.nan, math.inf def key(x): return x.cookies_amount def cookies_str(u): if isinstance(u, config.User): c = u.cookies_amount else: c = int(u) return str(c) if args and args[0].lower() == "top": if len(args) < 2: cursor = config.database.cursor() cursor.execute("select name from users " "where cookies != 0 "
import config import ch import html note = args.partition(" ")[2] args = args.split() cuser = None if user.name[0] in "#!" else config.User(user.name) lang = "en" if cuser is None else cuser.lang if not cuser: msg = config.get_lang("en", "not_for_anons") elif not args: msg = config.get_lang(lang, "missing_argument") arg = config.get_lang(lang, "argument_action") msg = msg.format(arg) elif args[0].lower() == "add": if not args[1:]: msg = config.get_lang(lang, "missing_argument") arg = config.get_lang(lang, "argument_note") msg = msg.format(arg) else: cuser.add_note(note) note_n = cuser.get_notes_len() msg = config.get_lang(lang, "added_note") msg = msg.format(note_n) elif args[0].lower() == "see": if not cuser.get_notes_len(): msg = config.get_lang(lang, "doesnt_has_notes") elif not args[1:]: msg = config.get_lang(lang, "notes_see_page") see_n = config.get_lang(lang, "notes_see_n")
import platform import sys import config lang = config.User(user.name).lang python = platform.python_implementation() + " " + platform.python_version() system = platform.system() + " " + platform.release() if sys.platform.startswith("linux"): distro_name, distro_ver, distro_id = platform.linux_distribution() system += " (" + distro_name + " " + distro_ver + ")" if hasattr(self, "start_time"): import utils delta = utils.delta_time(self.start_time) start_time = utils.str_delta(lang, delta) else: start_time = None msg = config.get_lang(lang, "platform").format(system) msg += "\n" + config.get_lang(lang, "python").format(python) if start_time: msg += "\n" + config.get_lang(lang, "start_time").format(start_time) room.message(msg)