Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db changes #370

Merged
merged 20 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions ChanServ.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, root, address, session_id):

self.username = 'ChanServ'
self.password = 'ChanServ'
self.lobby_id = 'ChanServ'
self.agent = 'ChanServ'
self._root.usernames[self.username] = self
self._root.clients[session_id] = self
self._root = root
Expand Down Expand Up @@ -216,10 +216,10 @@ def HandleCommand(self, user, cmd, chan=None, args=None):
return '#%s: You do not have permission to change history settings in the channel' % chan
if args=='on':
channel.setHistory(client, True)
return '#%s: History enabled' % (chan, str(enable))
return '#%s: History enabled' % chan
if args=='off':
channel.setHistory(client, False)
return '#%s: History disabled' % (chan, str(enable))
return '#%s: History disabled' % chan
return '#%s: Unknown value for history setting (expected: on, off).' % chan

if cmd == 'antispam':
Expand Down Expand Up @@ -467,6 +467,9 @@ def HandleCommand(self, user, cmd, chan=None, args=None):
antispam = "Anti-spam protection is off"
if channel.antispam:
antispam = "Anti-spam protection is on"
history = "Channel history is off"
if channel.store_history:
history = "Channel history is on"
founder = 'No founder is registered'
if channel.owner_user_id:
founder = self._root.clientFromID(channel.owner_user_id, True)
Expand All @@ -486,7 +489,8 @@ def HandleCommand(self, user, cmd, chan=None, args=None):
users_str = 'Currently contains 0 users and 0 bridged users'
if len(users)>=1 or len(bridged_users)>=1:
users_str = 'Currently contains %i users and %i bridged users' % (len(users), len(bridged_users))
return '#%s info: %s. %s. %s. %s. ' % (chan, antispam, founder, op_list, users_str)
used_str = "Last used on %s" % channel.last_used.strftime('%b %d, %Y')
return '#%s info: %s. %s. %s. %s. %s. %s.' % (chan, founder, op_list, users_str, antispam, history, used_str)

if not (len(cmd)>=3 and all(c.isalpha() for c in cmd)):
return #probably just a smiley or suchlike - not meant to invoke ChanServ
Expand Down
2 changes: 1 addition & 1 deletion Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, root, address, session_id):
self.compat = set() # holds compatibility flags

self.country_code = '??'
self.lobby_id = ""
self.agent = ""
self.setFlagByIP(self.ip_address)
self.status = 12
self.accesslevels = ['fresh','everyone']
Expand Down
10 changes: 7 additions & 3 deletions DataHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def _fk_pragma_on_connect(dbapi_con, con_record):
channel.key = dbchannel['key']
if channel.key in ('', None, '*'):
channel.key = None
channel.last_used = dbchannel['last_used']
if not channel.last_used: # can remove after first run!
channel.last_used = now
self.channeldb.recordUse(channel)

channel.topic_user_id = dbchannel['topic_user_id']
channel.topic = dbchannel['topic']
Expand Down Expand Up @@ -733,10 +737,10 @@ def client_LoginStats(self, client):
self.flag_stats[flag] += 1
else:
self.flag_stats[flag] = 1
if client.lobby_id in self.agent_stats:
self.agent_stats[client.lobby_id] += 1
if client.agent in self.agent_stats:
self.agent_stats[client.agent] += 1
else:
self.agent_stats[client.lobby_id] = 1
self.agent_stats[client.agent] = 1

def reload(self, client):
# reload non-core parts of the server
Expand Down
Loading