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

Testbotk #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
59 changes: 31 additions & 28 deletions vodkabot.py → vodkabot2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def sendMessage(to, text, contentMetadata={}, contentType=0):

def NOTIFIED_ADD_CONTACT(op):
try:
sendMessage(op.param1, client.getContact(op.param1).displayName + "Thanks for add")
sendMessage(op.param1, client.getContact(op.param1).displayName + "Hi")
except Exception as e:
print e
print ("\n\nNOTIFIED_ADD_CONTACT\n\n")
Expand All @@ -60,7 +60,7 @@ def NOTIFIED_ACCEPT_GROUP_INVITATION(op):

def NOTIFIED_KICKOUT_FROM_GROUP(op):
try:
sendMessage(op.param1, client.getContact(op.param3).displayName + " Good Bye\n(*´・ω・*)")
sendMessage(op.param1, client.getContact(op.param3).displayName + " 被踢了拉 嗚嗚嗚")
except Exception as e:
print e
print ("\n\nNOTIFIED_KICKOUT_FROM_GROUP\n\n")
Expand All @@ -70,7 +70,7 @@ def NOTIFIED_KICKOUT_FROM_GROUP(op):

def NOTIFIED_LEAVE_GROUP(op):
try:
sendMessage(op.param1, client.getContact(op.param2).displayName + " Good Bye\n(*´・ω・*)")
sendMessage(op.param1, client.getContact(op.param2).displayName + " 退了.....")
except Exception as e:
print e
print ("\n\nNOTIFIED_LEAVE_GROUP\n\n")
Expand Down Expand Up @@ -141,12 +141,15 @@ def SEND_MESSAGE(op):
sendMessage(msg.to, msg.to)
if msg.text == "ginfo":
group = client.getGroup(msg.to)
md = "[Group Name]\n" + group.name + "\n\n[gid]\n" + group.id + "\n\n[Group Picture]\nhttp://dl.profile.line-cdn.net/" + group.pictureStatus
if group.preventJoinByTicket is False: md += "\n\nInvitationURL: Permitted\n"
else: md += "\n\nInvitationURL: Refusing\n"
if group.invitee is None: md += "\nMembers: " + str(len(group.members)) + "人\n\nInviting: 0People"
else: md += "\nMembers: " + str(len(group.members)) + "People\nInvited: " + str(len(group.invitee)) + "People"
md = "ㄌㄑ愛ㄎㄩ\n\n[群組名稱]\n" + group.name + "\n\n[群組gid]\n" + group.id + "\n\n[群組照片]\nhttp://dl.profile.line-cdn.net/" + group.pictureStatus
if group.preventJoinByTicket is False: md += "\n\n群組URL: 許可中\n"
else: md += "\n\n群組URL: 關閉中\n"
if group.invitee is None: md += "\n成員人數: " + str(len(group.members)) + "人\n\n招待中人數: 0人"
else: md += "\n成員人數: " + str(len(group.members)) + "人\n招待中人數: " + str(len(group.invitee)) + ""
sendMessage(msg.to,md)
if msg.text == "help":
sendMessage(msg.to,"ㄌㄑandㄎㄩ 專屬help\n\n[mid] 查看自己的mid\n" + "[gid] 查看群組gid\n" + "[me︎] 送出自己的友資\n[ginfo] 查看群組詳細資料\n" + "[url] 取得群組網址\n[urlon] 開啟群組網址\n[urloff] 關閉群組網址\n[kick:] 利用mid踢人\n" +
"[Nk:] 利用名字踢人(完整用戶名稱)\n" + "[cancel] 取消全部邀請\n[invite:] 利用mid邀請\n[show:] 顯示mid得友資\n[set] 設定已讀點\n[read] 顯示已讀用戶\n[time] 顯示現在時間\n[gift] 發送禮物\n\n\n\n[" + datetime.datetime.today().strftime('%Y年%m月%d日 %H:%M:%S') + "]")
if "gname:" in msg.text:
key = msg.text[22:]
group = client.getGroup(msg.to)
Expand All @@ -155,54 +158,54 @@ def SEND_MESSAGE(op):
sendMessage(msg.to,"Group Name"+key+"Canged to")
if msg.text == "url":
sendMessage(msg.to,"line://ti/g/" + client._client.reissueGroupTicket(msg.to))
if msg.text == "open":
if msg.text == "urlon":
group = client.getGroup(msg.to)
if group.preventJoinByTicket == False:
sendMessage(msg.to, "already open")
sendMessage(msg.to, "網址早就開了")
else:
group.preventJoinByTicket = False
client.updateGroup(group)
sendMessage(msg.to, "URL Open")
if msg.text == "close":
sendMessage(msg.to, "ㄌㄑ已開啟群組URL")
if msg.text == "urloff":
group = client.getGroup(msg.to)
if group.preventJoinByTicket == True:
sendMessage(msg.to, "already close")
sendMessage(msg.to, "網址早就關了")
else:
group.preventJoinByTicket = True
client.updateGroup(group)
sendMessage(msg.to, "URL close")
sendMessage(msg.to, "ㄌㄑ已關閉群組URL")
if "kick:" in msg.text:
key = msg.text[5:]
client.kickoutFromGroup(msg.to, [key])
contact = client.getContact(key)
sendMessage(msg.to, ""+contact.displayName+"sorry")
if "nk:" in msg.text:
sendMessage(msg.to, ""+contact.displayName+"被我踢了><")
if "Nk:" in msg.text:
key = msg.text[3:]
group = client.getGroup(msg.to)
Names = [contact.displayName for contact in group.members]
Mids = [contact.mid for contact in group.members]
if key in Names:
kazu = Names.index(key)
sendMessage(msg.to, "Bye")
sendMessage(msg.to, "ㄌㄑandㄎㄩ 跟你說掰掰~")
client.kickoutFromGroup(msg.to, [""+Mids[kazu]+""])
contact = client.getContact(Mids[kazu])
sendMessage(msg.to, ""+contact.displayName+" Sorry")
sendMessage(msg.to, ""+contact.displayName+" 被我踢了 嘿嘿")
else:
sendMessage(msg.to, "wtf?")
sendMessage(msg.to, "沒有找到這位成員><")
if msg.text == "cancel":
group = client.getGroup(msg.to)
if group.invitee is None:
sendMessage(op.message.to, "No one is inviting.")
sendMessage(op.message.to, "沒有邀請了昂><")
else:
gInviMids = [contact.mid for contact in group.invitee]
client.cancelGroupInvitation(msg.to, gInviMids)
sendMessage(msg.to, str(len(group.invitee)) + " Done")
sendMessage(msg.to, str(len(group.invitee)) + "人已被ㄌㄑ取消~")
if "invite:" in msg.text:
key = msg.text[-33:]
client.findAndAddContactsByMid(key)
client.inviteIntoGroup(msg.to, [key])
contact = client.getContact(key)
sendMessage(msg.to, ""+contact.displayName+" I invited you")
sendMessage(msg.to, ""+contact.displayName+" 已經被ㄌㄑ邀請了~")
if msg.text == "me":
M = Message()
M.to = msg.to
Expand All @@ -213,13 +216,13 @@ def SEND_MESSAGE(op):
key = msg.text[-33:]
sendMessage(msg.to, text=None, contentMetadata={'mid': key}, contentType=13)
contact = client.getContact(key)
sendMessage(msg.to, ""+contact.displayName+"'s contact")
sendMessage(msg.to, ""+contact.displayName+"的友資~")
if msg.text == "time":
sendMessage(msg.to, "Current time is" + datetime.datetime.today().strftime('%Y年%m月%d日 %H:%M:%S') + "is")
sendMessage(msg.to, "精確的時間為" + datetime.datetime.today().strftime('%Y年%m月%d日 %H:%M:%S') + "")
if msg.text == "gift":
sendMessage(msg.to, text="gift sent", contentMetadata=None, contentType=9)
if msg.text == "set":
sendMessage(msg.to, "I have set a read point ♪\n「tes」I will show you who I have read ♪")
sendMessage(msg.to, "ㄌㄑ已設定已讀點~")
try:
del wait['readPoint'][msg.to]
del wait['readMember'][msg.to]
Expand All @@ -230,7 +233,7 @@ def SEND_MESSAGE(op):
wait['setTime'][msg.to] = datetime.datetime.today().strftime('%Y-%m-%d %H:%M:%S')
wait['ROM'][msg.to] = {}
print wait
if msg.text == "tes":
if msg.text == "read":
if msg.to in wait['readPoint']:
if wait["ROM"][msg.to].items() == []:
chiya = ""
Expand All @@ -240,9 +243,9 @@ def SEND_MESSAGE(op):
print rom
chiya += rom[1] + "\n"

sendMessage(msg.to, "People who readed %s\nthat's it\n\nPeople who have ignored reads\n%sIt is abnormal ♪\n\nReading point creation date n time:\n[%s]" % (wait['readMember'][msg.to],chiya,setTime[msg.to]))
sendMessage(msg.to, "ㄌㄑ來抓已讀囉~\n\n已讀的人有:\n %s\n><\n\n已讀不回的人有:\n%s ♪\n\n已讀點設定時間:\n[%s]" % (wait['readMember'][msg.to],chiya,setTime[msg.to]))
else:
sendMessage(msg.to, "An already read point has not been set.\n「set」you can send ♪ read point will be created ♪")
sendMessage(msg.to, "笨ㄌㄑ還沒設已讀點拉><")
else:
pass
else:
Expand Down