As all know ,wechat ia a popular communication tool in China with 8 hundred million users.Just like the twitter and facebook
This is a tool that allows you to get a mention message through Wechat application when somebody in Steemit gives a upvote to your post.
Always , we do not sit before the computer to view Steemit for all of our time.So it is necessary to have a mention tool which can remind us of the latest new in the Steemit wherever and whenever we are.
The project uses a multi thread and the Producer-Consumer as the running framework.
There are 5 threads running at the same time
- one WechatMem
- one Producer
- three Consumer
Firstly,through the thread of WechatMem,get the member of the wechat group,who are the users will get the mention information of the Steemit upvote.
Secondly, while running the thread of Producer to get the latest data the the Steemit block,three threads of Consumer read the queue to get the related data of the upvote.
When getting the data related to the member of the group ,the bot will send a direct message to the user in the Wechat application.
- Python 3.6
- Steempython
- wxpy
-
Install Python 3.6
-
Install Steempython
For installing the Steempython lib , you had better use Ubuntu system instead of Windows system.
pip install -U steem
-
Install wxpy
pip install -U wxpy
-
Get the code of this project
git pull https://github.com/Cha0s0000/SteemitWechatBot.git
-
Edit the code
class WechatMem(threading.Thread): def __init__(self,name,bot,MemberList): threading.Thread.__init__(self,name=name) self.bot=bot self.MemberList=MemberList def run(self): while True: SteemitBotWechatGroup = ensure_one(self.bot.groups().search('SteemitBot')) SteemitBotWechatGroup.update_group(True) for member in SteemitBotWechatGroup: friend = ensure_one(self.bot.friends().search(member.name)) if (friend.name !=""): # print(friend.remark_name) if friend.name in self.MemberList: continue else: self.MemberList.append(friend.name) print('update SteemitBot list') print(self.MemberList) time.sleep(10)
class Consumer(threading.Thread): def __init__(self,name,queue,MemberList,bot): threading.Thread.__init__(self,name=name) self.data=queue self.MemberList=MemberList self.bot=bot def run(self): while True: operations = self.data.get() if operations != None: for op in operations: # print(op) if op[0] == 'vote': if op[1]['author'] in self.MemberList: voter = op[1]['voter'] author = op[1]['author'] weight = op[1]['weight'] permlink = 'https://steemit.com/@'+author+'/'+op[1]['permlink'] postdata = json.dumps(op[1]) print(self.MemberList) print("\n") print(postdata) InformFriend = ensure_one(self.bot.friends().search(author)) InformFriend.send("@{}\n--------\n你的文章有新点赞\n————————————\nvoter:{}\nweight:{}\npermlink:\n{} ".format(author,voter,weight,permlink))
-
Run the code
python main.py