Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

代码排版 & online 输出格式优化

  • Loading branch information...
commit fc8925b3c06ff79017024766c2e61404ce16d8e1 1 parent 06c60f3
依云 lilydjwg authored
Showing with 51 additions and 53 deletions.
  1. +51 −53 m2ggg_core.py
104 m2ggg_core.py
View
@@ -484,94 +484,92 @@ def is_all_cmd(self, str, user, nick, idf=""):
logging.error("NAME_x:"+us)
l=db.GqlQuery("SELECT __key__ FROM UserListExpNewExt WHERE fix_name = :1 AND usertype = :2 AND open_time < :3",us,0,int(round(time.time())))
##block someone function check
- uid=make_idcode(user)
- blk=db.GqlQuery("SELECT * FROM BlockUser WHERE from_name = :1",uid)
- blkh={}
+ uid = make_idcode(user)
+ blk = db.GqlQuery("SELECT * FROM BlockUser WHERE from_name = :1", uid)
+ blkh = {}
for x in blk:
- blkh[x.to_name]=True
- self.reply="FAILED"
+ blkh[x.to_name] = True
+ self.reply = "FAILED"
for e in l:
logging.error("NAME:"+e.name())
- if (not check_hash(blkh,make_idcode(e.name()))):
+ if not check_hash(blkh,make_idcode(e.name())):
if sendmsg('@[m] '+nick+"("+idf+") : "+wd,e.name()):
- self.reply="OK"
+ self.reply = "OK"
return True
- if cmdc=="online":
- self.cmdname=str[0:8]
+
+ if cmdc == "online":
+ self.cmdname = str[0:8]
try:
- l=db.GqlQuery("SELECT * FROM UserListExpNewExt WHERE is_blacklist = :1",False)
- if (l==None):
+ l = db.GqlQuery("SELECT * FROM UserListExpNewExt WHERE is_blacklist = :1", False)
+ if l is None:
logging.error("OH!")
return True
- self.reply="\n"
- g=0
+ self.reply = ''
+ g = 0
for e in l:
- mid=e.fix_name
+ mid = e.fix_name
try:
- if cached_xmpp_user_check((e.key().name())):
- self.reply+=e.nick_name+"("+mid+")\n"
- g=g+1
+ if cached_xmpp_user_check(e.key().name()):
+ self.reply += "%s\t(%s)\n" % (e.nick_name, mid)
+ g += 1
except:
pass
- self.reply+="\n total:"
- b="%ld" % g
- self.reply+=b
- #### ####
+ self.reply += "\n共: %ld" % g
return True
except:
- logging.error("Some!")
+ logging.error("online cmd failed!")
return False
return False
#check if is a command
- def is_cmd(self,str):
- if str[0:2]!="//":
+ def is_cmd(self, str):
+ if str[0:2] != "//":
return False
- v=string.find(str," ")
- if (v<0):
- v=len(str)
- cmdc=str[2:v]
- if cmdc=="whois":
- self.cmdname=str[0:7]
- n=str[8:]
- l=db.GqlQuery("SELECT __key__ FROM UserListExpNewExt WHERE fix_name = :1 AND usertype = :2",n,0)
- if not (l==None) :
+ v = str.find(" ")
+ if v < 0:
+ v = len(str)
+ cmdc = str[2:v]
+ if cmdc == "whois":
+ self.cmdname = str[0:7]
+ n = str[8:]
+ l = db.GqlQuery("SELECT __key__ FROM UserListExpNewExt WHERE fix_name = :1 AND usertype = :2",n,0)
+ if l is not None :
try:
- self.reply=l.name()
+ self.reply = l.name()
except:
- self.reply=""
+ self.reply = ""
try:
for e in l :
- self.reply+=e.name()+"\n"
+ self.reply += e.name() + "\n"
except:
pass
else:
- self.reply="not exists or is hidden"
+ self.reply = "not exists or is hidden"
return True
if cmdc=="blacklist":
self.cmdname=str[0:11]
n=str[12:].lower().strip()
nk=UserListExpNewExt.get_by_key_name(n)
- nk.is_blacklist=True
+ nk.is_blacklist = True
nk.put()
- self.reply=""+n+" turn to Black now."
+ self.reply = n + " turn to Black now."
return True
- if cmdc=="pass":
+ if cmdc == "pass":
self.cmdname=str[0:6]
n=str[7:].lower().strip()
nk=UserListExpNewExt.get_by_key_name(n)
nk.is_blacklist=False
nk.put()
- self.reply=""+n+" Black sign has removed."
+ self.reply = n + " Black sign has removed."
return True
- if cmdc=="admin":
- self.cmdname=str[0:7]
- n=str[8:].lower().strip()
- nk=UserListExpNewExt.get_by_key_name(n)
- nk.is_admin=True
+ if cmdc == "admin":
+ self.cmdname = str[0:7]
+ n = str[8:].lower().strip()
+ nk = UserListExpNewExt.get_by_key_name(n)
+ nk.is_admin = True
nk.put()
- self.reply=""+n+" is admin now"
+ self.reply = n + " is admin now"
return True
if cmdc=="unadmin":
self.cmdname=str[0:9]
@@ -579,9 +577,9 @@ def is_cmd(self,str):
nk=UserListExpNewExt.get_by_key_name(n)
nk.is_admin=False
nk.put()
- self.reply=""+n+" Admin sign has removed."
+ self.reply = n + " Admin sign has removed."
return True
- if cmdc=="add":
+ if cmd c== "add":
self.cmdname=str[0:5]
n=str[6:].lower().strip()
l=db.GqlQuery("SELECT __key__ FROM UserListExpNewExt WHERE nick_name = :1",n)
@@ -600,7 +598,7 @@ def is_cmd(self,str):
else:
self.reply+="User exists."
return True
- if cmdc=="addroutesend":
+ if cmdc == "addroutesend":
self.cmdname=str[0:14]
n=str[15:].lower().strip() # name key url
q1=string.find(n," ")
@@ -652,9 +650,9 @@ def is_cmd(self,str):
logging.error("delete failed")
self.reply += "Done.\n"
return True
- if cmdc=="listuser":
- self.cmdname=str[0:10]
- self.reply=m2ggg_config.msg_str_reserved
+ if cmdc == "listuser":
+ self.cmdname = str[0:10]
+ self.reply = m2ggg_config.msg_str_reserved
return True
return False
Please sign in to comment.
Something went wrong with that request. Please try again.