This repository has been archived by the owner on May 12, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,239 additions
and
1,239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
import time, ConfigParser | ||
def __init__ (): | ||
pass | ||
|
||
class Reaction: | ||
|
||
#canSay = ("Aquarion") | ||
|
||
__name = 'Base' | ||
|
||
cooldown_number = 6 | ||
cooldown_time = 360 | ||
uses = [] | ||
|
||
def __str__(self): | ||
return self.__name | ||
|
||
def __repr__(self): | ||
return '<%s Reaction>' % self | ||
|
||
|
||
def __init__(self, connection): | ||
pass | ||
|
||
|
||
def getconfig(self, connection): | ||
try: | ||
config = connection.config.items(self.__name) | ||
print "Haiku Config!" | ||
self.config = {} | ||
for item in config: | ||
self.config[item[0]] = item[1] | ||
except ConfigParser.NoSectionError: | ||
print "no config for %s" % self.__name | ||
pass | ||
|
||
|
||
#def privateAction(self, connection, user, channel, message, matchindex = 0): | ||
|
||
|
||
def overUsed(self, uses = False, number = False, cooldown = False): | ||
|
||
if (uses != False): | ||
print "Note: %s is still using the old overused syntax" % self.__name; | ||
|
||
|
||
if len(self.uses) >= self.cooldown_number: | ||
first_use = int(self.uses[0]) | ||
use_allowed_again = first_use + self.cooldown_time | ||
if time.time() < use_allowed_again: | ||
print "Use Blocked. Try again in %s" % (int(use_allowed_again) - time.time()); | ||
return True | ||
else: | ||
print "Now %s, Limit at %s (%d)" % (time.time(), use_allowed_again, time.time() - int(use_allowed_again) ) | ||
|
||
return False | ||
|
||
def updateOveruse(self): | ||
## Overuse Detectection ## | ||
self.uses.append(int(time.time())) | ||
if len(self.uses) > self.cooldown_number: | ||
self.uses = self.uses[1:self.cooldown_number] | ||
## Overuse Detectection ## | ||
import time, ConfigParser | ||
def __init__ (): | ||
pass | ||
|
||
class Reaction: | ||
|
||
#canSay = ("Aquarion") | ||
|
||
__name = 'Base' | ||
|
||
cooldown_number = 6 | ||
cooldown_time = 360 | ||
uses = [] | ||
|
||
def __str__(self): | ||
return self.__name | ||
|
||
def __repr__(self): | ||
return '<%s Reaction>' % self | ||
|
||
|
||
def __init__(self, connection): | ||
pass | ||
|
||
|
||
def getconfig(self, connection): | ||
try: | ||
config = connection.config.items(self.__name) | ||
print "Haiku Config!" | ||
self.config = {} | ||
for item in config: | ||
self.config[item[0]] = item[1] | ||
except ConfigParser.NoSectionError: | ||
print "no config for %s" % self.__name | ||
pass | ||
|
||
|
||
#def privateAction(self, connection, user, channel, message, matchindex = 0): | ||
|
||
|
||
def overUsed(self, uses = False, number = False, cooldown = False): | ||
|
||
if (uses != False): | ||
print "Note: %s is still using the old overused syntax" % self.__name; | ||
|
||
|
||
if len(self.uses) >= self.cooldown_number: | ||
first_use = int(self.uses[0]) | ||
use_allowed_again = first_use + self.cooldown_time | ||
if time.time() < use_allowed_again: | ||
print "Use Blocked. Try again in %s" % (int(use_allowed_again) - time.time()); | ||
return True | ||
else: | ||
print "Now %s, Limit at %s (%d)" % (time.time(), use_allowed_again, time.time() - int(use_allowed_again) ) | ||
|
||
return False | ||
|
||
def updateOveruse(self): | ||
## Overuse Detectection ## | ||
self.uses.append(int(time.time())) | ||
if len(self.uses) > self.cooldown_number: | ||
self.uses = self.uses[1:self.cooldown_number] | ||
## Overuse Detectection ## | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,80 @@ | ||
from lampstand import bible | ||
from lampstand.tools import splitAt | ||
import re, time, random, sys | ||
import lampstand.reactions.base | ||
|
||
def __init__ (): | ||
pass | ||
|
||
class Reaction(lampstand.reactions.base.Reaction): | ||
__name = 'Bible' | ||
|
||
cooldown_number = 3 | ||
cooldown_time = 120 | ||
uses = [] | ||
|
||
def __init__(self, connection): | ||
self.channelMatch = re.compile('%s. (\w*) (\d+\:\S+)' % connection.nickname, re.IGNORECASE) | ||
self.privateMatch = re.compile('(\w*) (\d+\:\S+)') | ||
|
||
def channelAction(self, connection, user, channel, message): | ||
matches = self.channelMatch.findall(message); | ||
|
||
|
||
if self.overUsed(): | ||
connection.msg(user, "Enough with the religion for now. (Overuse triggered)") | ||
return | ||
|
||
print "[Bible] %s" % matches | ||
|
||
bibleConnection = bible.ESVSession() | ||
result = bibleConnection.doPassageQuery('%s %s' % (matches[0][0], matches[0][1])) | ||
|
||
result = ' '.join(result.split('\n')) | ||
|
||
self.updateOveruse() | ||
|
||
if len(result) > 880*2: | ||
|
||
whereToSplit = splitAt(result, 860) | ||
result = "%s [Cut for length]" % result[0:whereToSplit] | ||
|
||
if len(result) > 440: | ||
whereToSplit = splitAt(result, 440) | ||
stringOne = result[0:whereToSplit] | ||
stringTwo = result[whereToSplit:] | ||
|
||
connection.msg(channel, "%s... " % stringOne) | ||
connection.msg(channel, "... %s [ESV]" % stringTwo) | ||
else: | ||
connection.msg(channel, "%s [ESV]" % result) | ||
|
||
return True | ||
|
||
def privateAction(self, connection, user, channel, message): | ||
matches = self.privateMatch.findall(message); | ||
|
||
|
||
print "[Bible] %s" % matches | ||
|
||
bibleConnection = bible.ESVSession() | ||
result = bibleConnection.doPassageQuery('%s %s' % (matches[0][0], matches[0][1])) | ||
|
||
result = ' '.join(result.split('\n')) | ||
|
||
if len(result) > 880*2: | ||
|
||
whereToSplit = splitAt(result, 860) | ||
result = "%s [Cut for length]" % result[0:whereToSplit] | ||
|
||
if len(result) > 440: | ||
whereToSplit = splitAt(result, 440) | ||
stringOne = result[0:whereToSplit] | ||
stringTwo = result[whereToSplit:] | ||
|
||
connection.msg(user, "%s... " % stringOne) | ||
connection.msg(user, "... %s [ESV]" % stringTwo) | ||
else: | ||
connection.msg(user, "%s [ESV]" % result) | ||
|
||
return True | ||
from lampstand import bible | ||
from lampstand.tools import splitAt | ||
import re, time, random, sys | ||
import lampstand.reactions.base | ||
|
||
def __init__ (): | ||
pass | ||
|
||
class Reaction(lampstand.reactions.base.Reaction): | ||
__name = 'Bible' | ||
|
||
cooldown_number = 3 | ||
cooldown_time = 120 | ||
uses = [] | ||
|
||
def __init__(self, connection): | ||
self.channelMatch = re.compile('%s. (\w*) (\d+\:\S+)' % connection.nickname, re.IGNORECASE) | ||
self.privateMatch = re.compile('(\w*) (\d+\:\S+)') | ||
|
||
def channelAction(self, connection, user, channel, message): | ||
matches = self.channelMatch.findall(message); | ||
|
||
|
||
if self.overUsed(): | ||
connection.msg(user, "Enough with the religion for now. (Overuse triggered)") | ||
return | ||
|
||
print "[Bible] %s" % matches | ||
|
||
bibleConnection = bible.ESVSession() | ||
result = bibleConnection.doPassageQuery('%s %s' % (matches[0][0], matches[0][1])) | ||
|
||
result = ' '.join(result.split('\n')) | ||
|
||
self.updateOveruse() | ||
|
||
if len(result) > 880*2: | ||
|
||
whereToSplit = splitAt(result, 860) | ||
result = "%s [Cut for length]" % result[0:whereToSplit] | ||
|
||
if len(result) > 440: | ||
whereToSplit = splitAt(result, 440) | ||
stringOne = result[0:whereToSplit] | ||
stringTwo = result[whereToSplit:] | ||
|
||
connection.msg(channel, "%s... " % stringOne) | ||
connection.msg(channel, "... %s [ESV]" % stringTwo) | ||
else: | ||
connection.msg(channel, "%s [ESV]" % result) | ||
|
||
return True | ||
|
||
def privateAction(self, connection, user, channel, message): | ||
matches = self.privateMatch.findall(message); | ||
|
||
|
||
print "[Bible] %s" % matches | ||
|
||
bibleConnection = bible.ESVSession() | ||
result = bibleConnection.doPassageQuery('%s %s' % (matches[0][0], matches[0][1])) | ||
|
||
result = ' '.join(result.split('\n')) | ||
|
||
if len(result) > 880*2: | ||
|
||
whereToSplit = splitAt(result, 860) | ||
result = "%s [Cut for length]" % result[0:whereToSplit] | ||
|
||
if len(result) > 440: | ||
whereToSplit = splitAt(result, 440) | ||
stringOne = result[0:whereToSplit] | ||
stringTwo = result[whereToSplit:] | ||
|
||
connection.msg(user, "%s... " % stringOne) | ||
connection.msg(user, "... %s [ESV]" % stringTwo) | ||
else: | ||
connection.msg(user, "%s [ESV]" % result) | ||
|
||
return True |
Oops, something went wrong.