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
Now deprecated in favor of https://git.steelbea.me/iou1name/fulvia

1
bot.py
View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
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
if sys.version_info.major >= 3:
basestring = (str, bytes)
# Can be implementation-dependent
_regex_type = type(re.compile(''))
@ -166,13 +163,13 @@ def clean_callable(func, config):
if not hasattr(func, 'event'):
func.event = ['PRIVMSG']
else:
if isinstance(func.event, basestring):
if isinstance(func.event, (str, bytes)):
func.event = [func.event.upper()]
else:
func.event = [event.upper() for event in func.event]
if hasattr(func, 'rule'):
if isinstance(func.rule, basestring):
if isinstance(func.rule, (str, bytes)):
func.rule = [func.rule]
func.rule = [compile_rule(nick, rule) for rule in func.rule]
@ -213,7 +210,7 @@ def clean_module(module, config):
shutdowns = []
jobs = []
urls = []
for obj in itervalues(vars(module)):
for key, obj in dict.items(vars(module)):
if callable(obj):
if getattr(obj, '__name__', None) == 'shutdown':
shutdowns.append(obj)

View File

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

View File

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

View File

@ -36,7 +36,8 @@ def roomTemp(bot, trigger):
"""
try:
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)
except requests.exceptions.ReadTimeout:
return bot.say("Connection error. Timeout reached.")

View File

@ -15,11 +15,6 @@ import pytz
from module import commands, example, NOLIMIT
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):
"""
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'):
base = 'http://www.bing.com/search?mkt=%s&q=' % lang
bytes = requests.get(base + query)
m = r_bing.search(bytes)
res = requests.get(base + query)
m = r_bing.search(res.text)
if m:
return m.group(1)
@ -39,12 +39,12 @@ r_duck = re.compile(r'nofollow" class="[^"]+" href="(?!https?:\/\/r\.search\.yah
def duck_search(query):
query = query.replace('!', '')
uri = 'http://duckduckgo.com/html/?q=%s&kl=uk-en' % query
bytes = requests.get(uri)
if 'requests-result' in bytes: # filter out the adds on top of the page
bytes = bytes.split('requests-result')[1]
m = r_duck.search(bytes)
res = requests.get(uri)
if 'requests-result' in res.text: # filter out the adds on top of the page
res.text = rex.text.split('requests-result')[1]
m = r_duck.search(res.text)
if m:
return requests.decode(m.group(1))
return res.text
# Alias google_search to duck_search
google_search = duck_search

View File

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