-
Notifications
You must be signed in to change notification settings - Fork 233
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
implement basic ding-dong bot #39
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e6e30f1
add pip packages to requirements.txt
wj-Mcat 9b82908
imp ding-dong bot
wj-Mcat 8e87f27
update git config & ding-dong example
wj-Mcat b643e35
update ding-dong-bot
wj-Mcat aca6b59
complete base puppet & puppet_hostie
wj-Mcat cc22602
resolve asyncio loop bug
wj-Mcat 3c898d0
Merge branch 'master' into master
huan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
#!/usr/bin/env python3.8 | ||
"""doc""" | ||
import asyncio | ||
|
||
from wechaty import Wechaty | ||
from wechaty.user import Message | ||
|
||
|
||
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') | ||
|
||
bot = Wechaty(token='your-token-here').on('message', message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we follow the same That will be a convenience for the developers who are using multiple languages to develop the wechaty program. export interface WechatyOptions {
memory? : MemoryCard,
name? : string, // Wechaty Name
// @deprecated: use `name` instead of `profile`
profile? : null | string, // DEPRECATED: use name instead
puppet? : PuppetModuleName | Puppet, // Puppet name or instance
puppetOptions? : PuppetOptions, // Puppet TOKEN
ioToken? : string, // Io TOKEN
} |
||
|
||
|
||
async def main(): | ||
"""doc""" | ||
print('hello') | ||
await asyncio.sleep(1) | ||
print('world') | ||
bot = Wechaty() | ||
print(await bot.name()) | ||
|
||
await bot.start() | ||
await do_some_thing() | ||
|
||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,7 @@ pylint-quotes | |
pytest | ||
pytype | ||
semver | ||
grpclib | ||
pyee | ||
requests | ||
qrcode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
grpclib | ||
huan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pyee | ||
requests | ||
qrcode |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we export Message in our module root? Because it will be convenience for the developers using, and that's also what we did in TS: