Git Product home page Git Product logo

Comments (4)

x23piracy avatar x23piracy commented on June 15, 2024

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

  1. Choice1
  2. Choice2
  3. 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.

x23piracy avatar x23piracy commented on June 15, 2024

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.

joaoricardo000 avatar joaoricardo000 commented on June 15, 2024

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.

abdhan avatar abdhan commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.