diff options
Diffstat (limited to 'cgi/weabot.py')
-rwxr-xr-x | cgi/weabot.py | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/cgi/weabot.py b/cgi/weabot.py index e0e941a..ff3c9d3 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -126,6 +126,8 @@ class weabot(object): self._newcookies = None def run(self): + clearCache() + path_split = self.environ["PATH_INFO"].split("/") caught = False @@ -454,7 +456,7 @@ class weabot(object): # Disallow posting if the site OR board is in maintenance if Settings.MAINTENANCE and board["dir"] != 'polka': raise UserError(_("%s is currently under maintenance. We'll be back.") % Settings.SITE_TITLE) - if board["locked"] == '1': + if board["locked"] == 1: raise UserError(_("This board is closed. You can't post in it.")) # create post object @@ -471,17 +473,17 @@ class weabot(object): parent_timestamp = parent_post['timestamp'] post["parentid"] = parent_post['id'] post["bumped"] = parent_post['bumped'] - if parent_post['locked'] == '1': + if parent_post['locked'] == 1: raise UserError(_("The thread is closed. You can't post in it.")) # check if the user is flooding flood_check(t, post, board["id"]) # use fields only if enabled - if board["disable_name"] != '1': + if not board["disable_name"]: post["name"] = cleanString(name) post["email"] = cleanString(email, quote=True) - if board["disable_subject"] != '1': + if not board["disable_subject"]: post["subject"] = cleanString(subject) # process tripcodes @@ -495,7 +497,7 @@ class weabot(object): if not post["parentid"] and board["dir"] not in ['bai', 'world']: # creating thread - __extend = re.compile(r"^!extend(:\w+)(:\w+)?\n") + __extend = re.compile(r"!extend(:\w+)(:\w+)?\n", re.IGNORECASE) res = __extend.match(message) if res: extend = res.groups() @@ -510,7 +512,8 @@ class weabot(object): # add function messages if extend_str: - extend_str = extend_str.replace('!extend', 'EXTEND') + extend_str = extend_str[1:] + extend_str = extend_str.replace('extend', 'EXTEND') post["message"] += '<hr />' + extend_str + ' configurado.' if not post["parentid"] and post["email"].lower() == 'sage': @@ -527,12 +530,6 @@ class weabot(object): capcode = Settings.CAPCODES[post["name"]] if post["tripcode"] == (Settings.TRIP_CHAR + capcode[0]): post["name"], post["tripcode"] = capcode[1], capcode[2] - # if board['board_type'] == '1': - # post["name"], post["tripcode"] = capcode[1], '' - # else: - # post["name"] = post["tripcode"] = '' - # post["message"] = ('[<span style="color:red">%s</span>]<br />' % capcode[2]) + post["message"] - cap_id, hide_end, use_icon = capcode[3], capcode[4], capcode[5] # hide ip if necessary @@ -566,28 +563,28 @@ class weabot(object): try: # 1: ID if extend[0] == ':no': - board["useid"] = '0' + board["useid"] = 0 elif extend[0] == ':yes': - board["useid"] = '1' + board["useid"] = 1 elif extend[0] == ':force': - board["useid"] = '2' + board["useid"] = 2 elif extend[0] == ':extra': - board["useid"] = '3' + board["useid"] = 3 # 2: Slip if extend[1] == ':no': - board["slip"] = '0' + board["slip"] = 0 elif extend[1] == ':yes': - board["slip"] = '1' + board["slip"] = 1 elif extend[1] == ':domain': - board["slip"] = '2' + board["slip"] = 2 elif extend[1] == ':verbose': - board["slip"] = '3' + board["slip"] = 3 elif extend[1] == ':country': - board["countrycode"] = '1' + board["countrycode"] = 1 elif extend[1] == ':all': - board["slip"] = '3' - board["countrycode"] = '1' + board["slip"] = 3 + board["countrycode"] = 1 except IndexError: pass @@ -743,7 +740,7 @@ class weabot(object): host = '*.' + host elif ':' in ip: iprs = ip.split(':') - host = '%s:%s:%s:%s:*.*.*.*' % (iprs[0], iprs[1], iprs[2], iprs[3]) + host = '%s:%s:*:*:*.*.*.*' % (iprs[0], iprs[1]) else: iprs = ip.split('.') host = '%s.%s.*.*' % (iprs[0], iprs[1]) @@ -824,7 +821,7 @@ class weabot(object): thread_length = threadNumReplies(post["parentid"]) # bump if not saged - if 'sage' not in post["email"].lower() and parent_post['locked'] != '2': + if 'sage' not in post["email"].lower() and parent_post['locked'] != 2: UpdateDb("UPDATE `posts` SET bumped = %s WHERE (`id` = %s OR `parentid` = %s) AND `boardid` = %s", (post["timestamp"], post["parentid"], post["parentid"], board["id"])) @@ -855,10 +852,10 @@ class weabot(object): if Settings.ENABLE_RSS: latestAdd(post, thread_length, postid, parent_post) # call discord hook - if Settings.ENABLE_DISCORD_HOOK and not post["parentid"]: + if Settings.ENABLE_DISCORD_HOOK: hook_url = make_url( postid, post, parent_post or post, True, False) - discord_hook(post, hook_url) + discord_hook(post, parent_post, hook_url) return (post_url, ttaken, postid) |