line-py icon indicating copy to clipboard operation
line-py copied to clipboard

how to make a read bot

Open Zero2627 opened this issue 7 years ago • 5 comments

I want to make a bot to get the mid who has read and then turn into name, finally send it to the group ......but I have some problem...... who can help me QAQ THANKS~~~

Zero2627 avatar Apr 07 '18 14:04 Zero2627

from linepy import *

client = LINE()
print(client.authToken)
tracer = OEPoll(client)

def NOTIFIED_READ_MESSAGE(op):
	try:
		gid = op.param1
		mid = op.param2
		name = client.getContact(mid).displayName
		client.sendMessage(to=gid, text=name)
	except Exception as e:
		print(e)

tracer.addOpInterrupt({
	OpType.NOTIFIED_READ_MESSAGE: NOTIFIED_READ_MESSAGE
	})

while True:
	tracer.trace()

I think that should work? been ages since ive used this, but 99% sure this'll work (if you're doing groupbot method; singletrace is slightly different)

doodspav avatar Apr 07 '18 23:04 doodspav

Hi I'm wondering what's the difference between singletrace and groupchat?

These two examples looks much the same. https://github.com/fadhiilrachman/line-py/blob/master/examples/groupbot.py https://github.com/fadhiilrachman/line-py/blob/master/examples/singletrace.py They all have the comment "This is sample for implement BOT in LINE group" Thank you

dnfatas avatar Apr 08 '18 02:04 dnfatas

@dnfatas single trace you have a single function for all op and you then do an if/else list or something like that op.type == OpType.RECEIVE_MESSAGE with groupbot you have a seperate function for each op

doodspav avatar Apr 08 '18 02:04 doodspav

In that 1% It false xxddd

OpType.NOTIFIED_READ_MESSAGE: NOTIFIED_READ_MESSAGE TypeError: addOpInterrupt() missing 1 required positional argument: 'DisposeFunc'

Zero2627 avatar Apr 08 '18 12:04 Zero2627

oh my bad, @Zero2627 its tracer.addOpInterruptWithDict (i missed out the WithDict)

doodspav avatar Apr 08 '18 17:04 doodspav