Skip to content

Commit

Permalink
Merge pull request #39 from wj-Mcat/master
Browse files Browse the repository at this point in the history
implement basic ding-dong bot
  • Loading branch information
huan authored May 9, 2020
2 parents 78466e1 + 3c898d0 commit af7f9f0
Show file tree
Hide file tree
Showing 50 changed files with 3,212 additions and 967 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ clean:
.PHONY: lint
lint: pylint pycodestyle flake8 mypy pytype


# disable: TODO list temporay
.PHONY: pylint
pylint:
pylint \
--load-plugins pylint_quotes \
--disable=W0511 \
$(SOURCE_GLOB)

.PHONY: pycodestyle
Expand All @@ -52,8 +55,8 @@ mypy:

.PHONE: pytype
pytype:
pytype src/
pytype examples/
pytype src/ --disable=import-error
pytype examples/ --disable=import-error

.PHONY: install
install:
Expand Down
37 changes: 29 additions & 8 deletions examples/ding-dong-bot.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
#!/usr/bin/env python3.8
"""doc"""
import asyncio

from wechaty import Wechaty
from wechaty.user import Message
from wechaty_puppet import PuppetOptions
from wechaty_puppet_hostie import HostiePuppet


async def message(msg: Message):
"""back on message"""
from_contact = msg.talker()
text = msg.text()
if from_contact is not None and text == 'ding':
await from_contact.say('dong')
print(msg)


async def do_some_thing():
"""do some thing"""
friends = await bot.Contact.find_all()
print(friends)
print('dong some thing')


# puppet_options = PuppetOptions(token='your-token-here')

bot: Wechaty = None

async def main():
"""doc"""
print('hello')
await asyncio.sleep(1)
print('world')
bot = Wechaty()
print(await bot.name())

hostie_puppet = HostiePuppet(PuppetOptions('donut-test-user-6005'),
'hostie-puppet')
global bot
bot = Wechaty(hostie_puppet).on('message', message)
await bot.start()
await do_some_thing()

asyncio.run(main())
Empty file added examples/event_bot.py
Empty file.
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ pylint-quotes
pytest
pytype==2020.2.20
semver
grpclib
pyee
requests
qrcode
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
grpclib
pyee
requests
qrcode
chatie-grpc==0.15.dev4
requests
qrcode
Loading

0 comments on commit af7f9f0

Please sign in to comment.