Comments (4)
Hi,
I have something like this done for my bot to rate soccer player in our group, when you type /rate you get presented a playername and text that says to rate the player type /rate 1..6
I can show you the code if you want but iam sure its dirty i am also new to python ;)
Regards X23
Am 11.02.2016 um 22:33 schrieb abdhan [email protected]:
Hi there,
I am a novice to python. I have been able to create simple views. But I am not sure how to create a poll like view.
For example:
Bot: Here's a question. Choose the right answer
- Choice1
- Choice2
- Choice3
I: 3
Bot: That is the right answer.
So now I was thinking to make like a new thread for the question. So that thread is only looking for a choice 1,2 or 3 while at the same time being able to listen to other commands from other users.
Any help is appreciated.Thanks in advance.
—
Reply to this email directly or view it on GitHub.
from whatsapp-bot-seed.
Hi,
it's not really a poll but goes in the right direction.
this is the code:
def rate(self, message=None, match=None, to=None): if message.isGroupMessage() == True: return TextMessageProtocolEntity("Die Spielerbewertung ist in der Gruppe nicht erlaubt, bitte durch Direktkonversation bewerten.", to=message.getFrom()) else: if len(message.getBody()) == 7: try: float(int(message.getBody()[6:])) except ValueError: return TextMessageProtocolEntity("Es sollten schon eine Zahl zwischen 0 und 6 sein Dumbo!", to=message.getFrom()) if os.path.exists(rank + message.getFrom()): for filename in os.listdir(user): if not os.path.exists(rank + message.getFrom() + "/" + filename): spielername = open(user + filename, "r") text_file = open(rank + message.getFrom() + "/" + filename, "w") text_file.write(message.getBody()[6:]) text_file.close() return TextMessageProtocolEntity("Du hast " + spielername.read() + " mit " + message.getBody()[6:] + " Punkte(n) bewertet. Sende /rate für die nächste Bewertung.", to=message.getFrom()) else: if os.path.exists(rank + message.getFrom()): for filename in os.listdir(user): if not os.path.exists(rank + message.getFrom() + "/" + filename): spielername = open(user + filename, "r") if os.path.exists(player + message.getFrom() + ".jpg"): playerpic = message.getFrom() + ".jpg" else: playerpic = "unknown.jpg" return self.image_sender.send_by_path(jid=message.getFrom(), path="/opt/whatsapp-bot-seed-master/media/player/" + playerpic, caption="Sende /rate (0..6) um " + spielername.read() + " zu bewerten.\r\n\r\n/rate 0 keine Wertung\r\n/rate 1 sehr gut\r\n/rate 2 gut\r\n/rate 3 befriedigend\r\n/rate 4 ausreichend\r\n/rate 5 mangelhaft\r\n/rate 6 ungenügend")
from whatsapp-bot-seed.
Hi,
on the last commit I added a QuizView, and a simple session storage.
3a8880c
check out:
https://github.com/joaoricardo000/whatsapp-bot-seed/blob/master/src/views/quiz.py
and
https://github.com/joaoricardo000/whatsapp-bot-seed/blob/master/src/utils/session.py
from whatsapp-bot-seed.
Thanks @x23piracy I will try it out.
@joaoricardo000 I did not know about the shelf module, so I will check that and try it out. Thanks a lot for the code! Cheers!
from whatsapp-bot-seed.
Related Issues (20)
- Information about this repository. HOT 9
- Receive "bad file descriptor" HOT 1
- Bot leaving group HOT 1
- Server has been started but not working when i message HOT 1
- After installing pip install -r opt/requirements.pip Bot is not Working
- Error few commands are not working
- not able to send and receive messages HOT 2
- How to install Whatsapp bot
- yowsup old version error HOT 2
- ImportError in RouteLayer HOT 1
- installing Requirements.pip
- Leave
- Proposing a PR to fix a few small typos
- Need help in understanding this whatsapp bot
- Error when extracting key use the yowsup-cli HOT 2
- Stating reasons for getting blocked often. HOT 1
- Google search not working because of API changes
- No reply from bot HOT 6
- how i get password? HOT 5
- TTS NOT WORKING HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whatsapp-bot-seed.