Browse files

docs/CHANGELOG checkit.

  • Loading branch information...
1 parent 4c82dd2 commit 9be5fd17297bcb8b100916419836b98659023e43 @Ferus committed Dec 3, 2011
View
19 Commands.py
@@ -66,8 +66,6 @@ def Quit(self, msg, sock, users, _allowed):
msg = msg
sock.quit(msg)
print("* [IRC] Quitting with message '{0}'.".format(msg))
- self.allowed.save()
- print("* [Allowed] Saving database.")
sock.close()
print("* [IRC] Closing Socket.")
quit()
@@ -79,7 +77,6 @@ def Access(self, msg, sock, users, _allowed):
Location = msg[3]
Text = msg[4]
try:
- levels = {0: self.allowed.addOwner, 1: self.allowed.addAdmin}
tmp = Text.split()[1:]
if tmp[0] == 'add':
@@ -90,14 +87,14 @@ def Access(self, msg, sock, users, _allowed):
sock.say(Location, "You cannot change your access.")
print("* [Access] Denied changing owners access.")
return None
-
- if int(tmp[3]) in levels.keys():
- levels[int(tmp[3])](tmp[1], tmp[2])
- else:
- self.allowed.addOther(tmp[1], tmp[2], int(tmp[3]))
-
- sock.say(Location, "{0}, {1} added at level {2}".format(tmp[1], tmp[2], tmp[3]))
- print("* [Access] {0}, {1} added at level {2}.".format(tmp[1], tmp[2], tmp[3]))
+
+ try:
+ self.allowed.Add(tmp[1], tmp[2], int(tmp[3]))
+ sock.say(Location, "{0}, {1} added at level {2}".format(tmp[1], tmp[2], tmp[3]))
+ print("* [Access] {0}, {1} added at level {2}.".format(tmp[1], tmp[2], tmp[3]))
+ except:
+ sock.say(Location, "Failed to update access for '{0}'".format(tmp[1]))
+ print("* [Access] Failed to update access for '{0}'".format(tmp[1]))
elif tmp[0] == 'del':
if self.allowed.levelCheck(tmp[1]):
View
15 Core.py
@@ -4,24 +4,23 @@
#Local Imports
import Parser
-import Allowed
-from Services import NickServ, HostServ
+from Services import NickServ, HostServ, Allowed
class Bot():
def __init__(self, nickname='', realname = '', ident = '', owner = [], ssl = True):
'''Create our bots name, realname, and ident, and create our IRC object, Commands object, Parser object, and users dict'''
- self.irc = blackbox_core.Core(logging=True, logfile="blackbox.txt", ssl=ssl)
+ self.irc = blackbox_core.Core(logging=False, ssl=ssl)
self.Nickserv = NickServ.NickServ(sock=self.irc)
self.Hostserv = HostServ.HostServ(sock=self.irc)
- self.allowed = Allowed.Users("AllowedUsers.shelve")
+ self.allowed = Allowed.Users("Services/AllowedUsers.shelve")
if owner:
- self.owner = owner
- self.allowed.owner = self.owner
- self.allowed.db[self.owner[0]] = [self.owner[1], self.owner[2]] #Reset the owner. Just in case the config changed.
- print("* [Access] Setting owner to {0}, with hostmask {1}".format(self.owner[0], self.owner[1]))
+ self.Owner = owner
+ self.allowed.Owner = self.Owner
+ self.allowed.db[self.Owner[0]] = [self.Owner[1], self.Owner[2]] #Reset the owner. Just in case the config changed.
+ print("* [Access] Setting owner to {0}, with hostmask {1}".format(self.Owner[0], self.Owner[1]))
self.p = Parser.Parse(sock=self.irc, allowed=self.allowed, nick=nickname)
View
2 Parser.py
@@ -6,7 +6,7 @@
#Local Imports
import Commands
-import Users as _U
+from Services import Users as _U
class Parse():
def __init__(self, sock=None, allowed=None, nick=None):
View
3 Plugins/GuessingGame.py
@@ -69,6 +69,7 @@ def Save(self):
for key in self.StatsDB.keys():
_db[key] = self.StatsDB[key]
_db.close()
+ print("* [Guess] Saving database")
return True
except:
return False
@@ -92,6 +93,8 @@ def AddStats(self, Player=None, Stat=None, Value=None):
self.StatsDB[Stat] = Value
else:
self.StatsDB[Stat] += Value
+
+ self.Save()
class GuessingGame(object):
View
180 Plugins/YouTube.py
@@ -13,7 +13,7 @@ def Main(self, link):
if not link:
return None
try:
- vidId = re.findall("v=[a-zA-Z0-9_\-]{11}", link)[0][2:]
+ vidId = re.findall("=[a-zA-Z0-9_\-]{11}", link)[0][1:]
jsonLink = "http://gdata.youtube.com/feeds/api/videos/{0}?alt=json".format(vidId)
jsonReply = requests.get(jsonLink)
if jsonReply.status_code != 200:
@@ -61,7 +61,7 @@ def Parse(self, jsonReply):
YouTube = YT()
def youtubestats(msg, sock, users, allowed):
- link = "http"+msg[4].split("http")[1].split(" ")[0]
+ link = re.split('(?:https?:\/\/)?(?:www\.)?youtube\.com\/.*?\s?', msg[4])[0]
x = YouTube.Main(link)
if x != None:
# [YouTube] title - By: author {duration} <averagerating/maxrating (percentrating%)> [x Likes/x Dislikes/x Total]
@@ -75,6 +75,180 @@ def youtubestats(msg, sock, users, allowed):
pass
hooks = {
- 'http:\/\/(?:www\.)?youtube\.com\/watch': [youtubestats, 5, False],
+ '(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch': [youtubestats, 5, False],
}
+#TODO - 'https://gdata.youtube.com/feeds/api/videos?q={0}&safeSearch=none&max-results=2&v=2&alt=json'
+#"+".join(searchTerm.replace("|","%7C").replace(" "," "))
+
+#{u'author': [{u'name': {u'$t': u'YouTube'},
+# u'uri': {u'$t': u'http://www.youtube.com/'}}],
+#u'category': [{u'scheme': u'http://schemas.google.com/g/2005#kind',
+# u'term': u'http://gdata.youtube.com/schemas/2007#video'}],
+#u'entry': [{u'author': [{u'name': {u'$t': u'NewWorld187TV'},
+# u'uri': {u'$t': u'https://gdata.youtube.com/feeds/api/users/newworld187tv'}}],
+# u'category': [{u'scheme': u'http://schemas.google.com/g/2005#kind',
+# u'term': u'http://gdata.youtube.com/schemas/2007#video'},
+# {u'label': u'Music',
+# u'scheme': u'http://gdata.youtube.com/schemas/2007/categories.cat',
+# u'term': u'Music'},
+# {u'scheme': u'http://gdata.youtube.com/schemas/2007/keywords.cat',
+# u'term': u'Twizted'},
+# {u'scheme': u'http://gdata.youtube.com/schemas/2007/keywords.cat',
+# u'term': u'New'},
+# {u'scheme': u'http://gdata.youtube.com/schemas/2007/keywords.cat',
+# u'term': u'World'},
+# {u'scheme': u'http://gdata.youtube.com/schemas/2007/keywords.cat',
+# u'term': u'187'},
+# {u'scheme': u'http://gdata.youtube.com/schemas/2007/keywords.cat',
+# u'term': u'TV'}],
+# u'content': {u'src': u'https://www.youtube.com/v/2cW3EX2EOkw?version=3&f=videos&app=youtube_gdata',
+# u'type': u'application/x-shockwave-flash'},
+# u'gd$comments': {u'gd$feedLink': {u'countHint': 77,
+# u'href': u'https://gdata.youtube.com/feeds/api/videos/2cW3EX2EOkw/comments?v=2'}},
+# u'gd$etag': u'W/"CUQCSX47eCp7I2A9WhRSGEk."',
+# u'gd$rating': {u'average': 4.3488374,
+# u'max': 5,
+# u'min': 1,
+# u'numRaters': 86,
+# u'rel': u'http://schemas.google.com/g/2005#overall'},
+# u'id': {u'$t': u'tag:youtube.com,2008:video:2cW3EX2EOkw'},
+# u'link': [{u'href': u'https://www.youtube.com/watch?v=2cW3EX2EOkw&feature=youtube_gdata',
+# u'rel': u'alternate',
+# u'type': u'text/html'},
+# {u'href': u'https://gdata.youtube.com/feeds/api/videos/2cW3EX2EOkw/responses?v=2',
+# u'rel': u'http://gdata.youtube.com/schemas/2007#video.responses',
+# u'type': u'application/atom+xml'},
+# {u'href': u'https://gdata.youtube.com/feeds/api/videos/2cW3EX2EOkw/related?v=2',
+# u'rel': u'http://gdata.youtube.com/schemas/2007#video.related',
+# u'type': u'application/atom+xml'},
+# {u'href': u'https://m.youtube.com/details?v=2cW3EX2EOkw',
+# u'rel': u'http://gdata.youtube.com/schemas/2007#mobile',
+# u'type': u'text/html'},
+# {u'href': u'https://gdata.youtube.com/feeds/api/videos/2cW3EX2EOkw?v=2',
+# u'rel': u'self',
+# u'type': u'application/atom+xml'}],
+# u'media$group': {u'media$category': [{u'$t': u'Music',
+# u'label': u'Music',
+# u'scheme': u'http://gdata.youtube.com/schemas/2007/categories.cat'}],
+# u'media$content': [{u'duration': 227,
+# u'expression': u'full',
+# u'isDefault': u'true',
+# u'medium': u'video',
+# u'type': u'application/x-shockwave-flash',
+# u'url': u'https://www.youtube.com/v/2cW3EX2EOkw?version=3&f=videos&app=youtube_gdata',
+# u'yt$format': 5},
+# {u'duration': 227,
+# u'expression': u'full',
+# u'medium': u'video',
+# u'type': u'video/3gpp',
+# u'url': u'rtsp://v4.cache7.c.youtube.com/CiILENy73wIaGQlMOoR9EbfF2RMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp',
+# u'yt$format': 1},
+# {u'duration': 227,
+# u'expression': u'full',
+# u'medium': u'video',
+# u'type': u'video/3gpp',
+# u'url': u'rtsp://v4.cache6.c.youtube.com/CiILENy73wIaGQlMOoR9EbfF2RMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp',
+# u'yt$format': 6}],
+# u'media$credit': [{u'$t': u'NewWorld187TV',
+# u'role': u'uploader',
+# u'scheme': u'urn:youtube'}],
+# u'media$description': {u'$t': u'awsome song',
+# u'type': u'plain'},
+# u'media$keywords': {u'$t': u'Twizted, New, World, 187, TV'},
+# u'media$license': {u'$t': u'youtube',
+# u'href': u'http://www.youtube.com/t/terms',
+# u'type': u'text/html'},
+# u'media$player': {u'url': u'https://www.youtube.com/watch?v=2cW3EX2EOkw&feature=youtube_gdata_player'},
+# u'media$restriction': [{u'$t': u'DE',
+# u'relationship': u'deny',
+# u'type': u'country'}],
+# u'media$thumbnail': [{u'height': 90,
+# u'time': u'00:01:53.500',
+# u'url': u'http://i.ytimg.com/vi/2cW3EX2EOkw/default.jpg',
+# u'width': 120,
+# u'yt$name': u'default'},
+# {u'height': 360,
+# u'url': u'http://i.ytimg.com/vi/2cW3EX2EOkw/hqdefault.jpg',
+# u'width': 480,
+# u'yt$name': u'hqdefault'},
+# {u'height': 90,
+# u'time': u'00:00:56.750',
+# u'url': u'http://i.ytimg.com/vi/2cW3EX2EOkw/1.jpg',
+# u'width': 120,
+# u'yt$name': u'start'},
+# {u'height': 90,
+# u'time': u'00:01:53.500',
+# u'url': u'http://i.ytimg.com/vi/2cW3EX2EOkw/2.jpg',
+# u'width': 120,
+# u'yt$name': u'middle'},
+# {u'height': 90,
+# u'time': u'00:02:50.250',
+# u'url': u'http://i.ytimg.com/vi/2cW3EX2EOkw/3.jpg',
+# u'width': 120,
+# u'yt$name': u'end'}],
+# u'media$title': {u'$t': u'Twizted-story of our lives',
+# u'type': u'plain'},
+# u'yt$duration': {u'seconds': u'227'},
+# u'yt$uploaded': {u'$t': u'2008-11-16T23:46:26.000Z'},
+# u'yt$videoid': {u'$t': u'2cW3EX2EOkw'}},
+# u'published': {u'$t': u'2008-11-16T23:46:26.000Z'},
+# u'title': {u'$t': u'Twizted-story of our lives'},
+# u'updated': {u'$t': u'2011-11-21T02:42:48.000Z'},
+# u'yt$accessControl': [{u'action': u'comment',
+# u'permission': u'allowed'},
+# {u'action': u'commentVote',
+# u'permission': u'allowed'},
+# {u'action': u'videoRespond',
+# u'permission': u'moderated'},
+# {u'action': u'rate',
+# u'permission': u'allowed'},
+# {u'action': u'embed',
+# u'permission': u'allowed'},
+# {u'action': u'list',
+# u'permission': u'allowed'},
+# {u'action': u'autoPlay',
+# u'permission': u'allowed'},
+# {u'action': u'syndicate',
+# u'permission': u'allowed'}],
+# u'yt$rating': {u'numDislikes': u'14', u'numLikes': u'72'},
+# u'yt$statistics': {u'favoriteCount': u'214',
+# u'viewCount': u'46459'}},
+#u'gd$etag': u'W/"D0INRHwycSp7I2A9WhRRGU0."',
+#u'generator': {u'$t': u'YouTube data API',
+# u'uri': u'http://gdata.youtube.com',
+# u'version': u'2.1'},
+#u'id': {u'$t': u'tag:youtube.com,2008:videos'},
+#u'link': [{u'href': u'https://www.youtube.com',
+# u'rel': u'alternate',
+# u'type': u'text/html'},
+# {u'href': u'https://gdata.youtube.com/feeds/api/videos?alt=json&q=Twiztid&start-index=1&max-results=2&safeSearch=none&oi=spell&spell=1&v=2',
+# u'rel': u'http://schemas.google.com/g/2006#spellcorrection',
+# u'title': u'Twiztid',
+# u'type': u'application/atom+xml'},
+# {u'href': u'https://gdata.youtube.com/feeds/api/videos?v=2',
+# u'rel': u'http://schemas.google.com/g/2005#feed',
+# u'type': u'application/atom+xml'},
+# {u'href': u'https://gdata.youtube.com/feeds/api/videos/batch?v=2',
+# u'rel': u'http://schemas.google.com/g/2005#batch',
+# u'type': u'application/atom+xml'},
+# {u'href': u'https://gdata.youtube.com/feeds/api/videos?alt=json&q=Twizted&start-index=1&max-results=2&safeSearch=none&v=2',
+# u'rel': u'self',
+# u'type': u'application/atom+xml'},
+# {u'href': u'https://gdata.youtube.com/feeds/api/videos?alt=atom-service&v=2',
+# u'rel': u'service',
+# u'type': u'application/atomsvc+xml'},
+# {u'href': u'https://gdata.youtube.com/feeds/api/videos?alt=json&q=Twizted&start-index=3&max-results=2&safeSearch=none&v=2',
+# u'rel': u'next',
+# u'type': u'application/atom+xml'}],
+#u'logo': {u'$t': u'http://www.youtube.com/img/pic_youtubelogo_123x63.gif'},
+#u'openSearch$itemsPerPage': {u'$t': 2},
+#u'openSearch$startIndex': {u'$t': 1},
+#u'openSearch$totalResults': {u'$t': 6003},
+#u'title': {u'$t': u'YouTube Videos matching query: Twizted'},
+#u'updated': {u'$t': u'2011-12-03T09:46:35.299Z'},
+#u'xmlns': u'http://www.w3.org/2005/Atom',
+#u'xmlns$gd': u'http://schemas.google.com/g/2005',
+#u'xmlns$media': u'http://search.yahoo.com/mrss/',
+#u'xmlns$openSearch': u'http://a9.com/-/spec/opensearch/1.1/',
+#u'xmlns$yt': u'http://gdata.youtube.com/schemas/2007'}
View
21 Allowed.py → Services/Allowed.py
@@ -10,43 +10,38 @@ def __init__(self, db=None):
if db:
self._dbFile = db
else:
- self._dbFile = "AllowedUsers.shelve"
+ self._dbFile = "Services/AllowedUsers.shelve"
_db = shelve.open(self._dbFile)
- self.db = self.dump(_db)
+ self.db = self.Load(_db)
_db.close()
self.keys = self.db.keys()
- self.owner = None
+ self.Owner = None
- def addOwner(self, nick, host):
- self.db[nick] = [host, 0]
-
- def addAdmin(self, nick, host):
- self.db[nick] = [host, 1]
-
- def addOther(self, nick, host, level):
- '''This is only temporary until I think of names for the others.'''
+ def Add[self, nick, host, level):
self.db[nick] = [host, int(level)]
+ self.Save()
def levelCheck(self, nick):
if nick in self.db.keys():
return nick, self.db[nick]
else:
return None
- def dump(self, db):
+ def Load(self, db):
x = {}
for key in db.keys():
x[key] = db[key]
return x
- def save(self):
+ def Save(self):
try:
_db = shelve.open(self._dbFile)
for key in self.db.keys():
_db[key] = self.db[key]
_db.close()
+ print("* [Allowed] Saving database.")
return True
except:
return False
View
0 Users.py → Services/Users.py
File renamed without changes.
View
3 WhergBot.py
@@ -6,7 +6,8 @@
nick = 'WhergBot' #Bots Nickname
real = 'WhergBot [Ferus]' #Bots realname
ident = 'Wherg' #Bots Ident
-channels = ['#hacking', '#lobby' ,'#4chon' ,'#circlejerk' ,'#tinyboard' ,'#animu']
+#channels = ['#hacking', '#lobby' ,'#4chon' ,'#circlejerk' ,'#tinyboard' ,'#animu']
+channels = ['#hacking']
owner = ['Ferus', 'anonymous@the.interwebs', 0] #Bots owner, [Nick, Ident@Host, Access Level]
ssl = True #To encrypt, Or to not encrypt, That is the question!
if ssl:
View
7 CHANGELOG → docs/CHANGELOG
@@ -1,3 +1,10 @@
+=== Dec 03 ===
++ Created a ./docs and moved some files to it.
++ Moved Users.py and Allowed.py to ./Services
++ Edited YouTube regex because people like to link w/o 'http://' >_>
++ Finished Stats for GuessingGame.py
++ GuessingGame.py and now Allowed.py call their Save() functions when something is added.
++ Edits reflecting upon the above (File path corrections, renamed some functions)
=== Dec 01 ===
+ Plugins now take the non-optional 'users' and 'allowed' in the called functions
+'users' is an Users.Users() object that holds the userlist for each channel.
View
0 LICENSE → docs/LICENSE
File renamed without changes.
View
0 NOTES → docs/NOTES
File renamed without changes.
View
0 TODO → docs/TODO
File renamed without changes.
View
0 InUseWhergBot.png → docs/WhergBotInUse.png
File renamed without changes

0 comments on commit 9be5fd1

Please sign in to comment.