last commit

This commit is contained in:
iou1name 2018-03-16 12:08:02 -04:00
parent e013a50711
commit 7dca597a2a
9 changed files with 188 additions and 198 deletions

View File

@ -2,3 +2,5 @@ NIGGER DICKS
NIGGER DICKS NIGGER DICKS
NIGGER DICKS NIGGER DICKS
NIGGER DICKS NIGGER DICKS
Now deprecated in favor of https://git.steelbea.me/iou1name/fulvia

3
bot.py
View File

@ -1,5 +1,4 @@
#! /usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" """
The core bot class. Say good bye to PYthon 2. The core bot class. Say good bye to PYthon 2.
""" """

View File

@ -9,9 +9,6 @@ import sys
from tools import itervalues, get_command_regexp from tools import itervalues, get_command_regexp
if sys.version_info.major >= 3:
basestring = (str, bytes)
# Can be implementation-dependent # Can be implementation-dependent
_regex_type = type(re.compile('')) _regex_type = type(re.compile(''))
@ -166,13 +163,13 @@ def clean_callable(func, config):
if not hasattr(func, 'event'): if not hasattr(func, 'event'):
func.event = ['PRIVMSG'] func.event = ['PRIVMSG']
else: else:
if isinstance(func.event, basestring): if isinstance(func.event, (str, bytes)):
func.event = [func.event.upper()] func.event = [func.event.upper()]
else: else:
func.event = [event.upper() for event in func.event] func.event = [event.upper() for event in func.event]
if hasattr(func, 'rule'): if hasattr(func, 'rule'):
if isinstance(func.rule, basestring): if isinstance(func.rule, (str, bytes)):
func.rule = [func.rule] func.rule = [func.rule]
func.rule = [compile_rule(nick, rule) for rule in func.rule] func.rule = [compile_rule(nick, rule) for rule in func.rule]
@ -213,7 +210,7 @@ def clean_module(module, config):
shutdowns = [] shutdowns = []
jobs = [] jobs = []
urls = [] urls = []
for obj in itervalues(vars(module)): for key, obj in dict.items(vars(module)):
if callable(obj): if callable(obj):
if getattr(obj, '__name__', None) == 'shutdown': if getattr(obj, '__name__', None) == 'shutdown':
shutdowns.append(obj) shutdowns.append(obj)

View File

@ -1,9 +1,6 @@
# coding=utf-8 #!/usr/bin/env python3
""" """
announce.py - Send a message to all channels Sends a message to all channels the bot is currently in.
Copyright © 2013, Elad Alfassa, <elad@fedoraproject.org>
Licensed under the Eiffel Forum License 2.
""" """
from module import commands, example from module import commands, example
@ -12,7 +9,7 @@ from module import commands, example
@example('.announce Some important message here') @example('.announce Some important message here')
def announce(bot, trigger): def announce(bot, trigger):
""" """
Send an announcement to all channels the bot is in Send an announcement to all channels the bot is in.
""" """
if not trigger.admin: if not trigger.admin:
bot.reply('Sorry, I can\'t let you do that') bot.reply('Sorry, I can\'t let you do that')

View File

@ -9,7 +9,6 @@ import random
from module import commands, example from module import commands, example
@commands("grog") @commands("grog")
@example(".grog")
def grog(bot, trigger): def grog(bot, trigger):
""" """
Picks a random status effect from Grog of Substantial Whimsy effect. Picks a random status effect from Grog of Substantial Whimsy effect.

View File

@ -36,7 +36,8 @@ def roomTemp(bot, trigger):
""" """
try: try:
res = requests.get("http://192.168.1.25/", timeout=10) res = requests.get("http://192.168.1.25/", timeout=10)
time.sleep(0.5) del res
time.sleep(1.5)
res = requests.get("http://192.168.1.25/", timeout=10) res = requests.get("http://192.168.1.25/", timeout=10)
except requests.exceptions.ReadTimeout: except requests.exceptions.ReadTimeout:
return bot.say("Connection error. Timeout reached.") return bot.say("Connection error. Timeout reached.")

View File

@ -15,11 +15,6 @@ import pytz
from module import commands, example, NOLIMIT from module import commands, example, NOLIMIT
from tools.time import get_timezone, format_time from tools.time import get_timezone, format_time
def filename(self):
name = self.nick + '-' + self.config.core.host + '.reminders.db'
return os.path.join(self.config.core.homedir, name)
def init_database(bot): def init_database(bot):
""" """
Initializes the 'remind' table in the bot's database. Does nothing if Initializes the 'remind' table in the bot's database. Does nothing if

View File

@ -28,8 +28,8 @@ r_bing = re.compile(r'<h3><a href="([^"]+)"')
def bing_search(query, lang='en-GB'): def bing_search(query, lang='en-GB'):
base = 'http://www.bing.com/search?mkt=%s&q=' % lang base = 'http://www.bing.com/search?mkt=%s&q=' % lang
bytes = requests.get(base + query) res = requests.get(base + query)
m = r_bing.search(bytes) m = r_bing.search(res.text)
if m: if m:
return m.group(1) return m.group(1)
@ -39,12 +39,12 @@ r_duck = re.compile(r'nofollow" class="[^"]+" href="(?!https?:\/\/r\.search\.yah
def duck_search(query): def duck_search(query):
query = query.replace('!', '') query = query.replace('!', '')
uri = 'http://duckduckgo.com/html/?q=%s&kl=uk-en' % query uri = 'http://duckduckgo.com/html/?q=%s&kl=uk-en' % query
bytes = requests.get(uri) res = requests.get(uri)
if 'requests-result' in bytes: # filter out the adds on top of the page if 'requests-result' in res.text: # filter out the adds on top of the page
bytes = bytes.split('requests-result')[1] res.text = rex.text.split('requests-result')[1]
m = r_duck.search(bytes) m = r_duck.search(res.text)
if m: if m:
return requests.decode(m.group(1)) return res.text
# Alias google_search to duck_search # Alias google_search to duck_search
google_search = duck_search google_search = duck_search

View File

@ -22,11 +22,11 @@ def setup(bot):
watching = cur.execute("SELECT * FROM watcher").fetchall() watching = cur.execute("SELECT * FROM watcher").fetchall()
except: except:
cur.execute("CREATE TABLE watcher(" cur.execute("CREATE TABLE watcher("
"api_url STRING PRIMARY KEY," "api_url TEXT PRIMARY KEY,"
"name STRING DEFAULT 'Anonymous'," "name TEXT DEFAULT 'Anonymous',"
"last_post INT," "last_post INT,"
"time_since STRING," "time_since TEXT,"
"channel STRING)") "channel TEXT)")
cur.commit() cur.commit()
else: else:
for thread in watching: for thread in watching: