python - How can I conduct a poll through an irc bot? -


I have set an IRC bot through the socket. I've added some commands, but I want to add the "pole" function . Ideally, the bot will get the command with this format:

! Poll & lt; Name & gt; & Lt; Opt1 & gt; & Lt; Opt2 & gt; & Lt; Opt3 & gt; & Lt; Time & gt;

At what time would I have to go about voting and end user checking after a certain time?

Thanks in advance,

Desperate Python Beginners.

Edit: Thanks for the people, I went with using the Global Wars (I know, I know) because I did not know how to do this otherwise, thank you very much !

OK, I'm starting to get some wild with my Python I think That I can answer - though this is not the best answer.

If you are planning to run multiple times, you can apply a dictionary that has many examples of custom classes like poles, here is a possible solution:

  class of politv (object): def __init __ (self): self.votes = [] self. Stoptime = "some date / time" # I can not remember how to do this bit;) def add_vote (Self, vote_value): self.votes.append (vote_value); Def tally_votes (self): return self.votes.size () def is_closed (self): if time_now & gt; = Self.stoptime: # I have forgotten how you actually do it, but it is for example Return True True: return incorrect # then use this poll_list = {} #irc processing ... if got_vote_command: If poll_list ["channel_or_poll_name"] You can not vote now. "Else: poll_list [" ("% D people are now voted!"% Poll_list ["channel_or_poll_name"]. Tally_votes ())  < / Pre> 

Of course, you have to edit the voting class to meet your needs, that is, to allow many values ​​in the vote, who votes to record (if you want to) Etc.

has ended, you can edit the voting class to stop the voting time, and one such Work is that which is right / wrong whether the time has elapsed or not. See docs for datetime modules ...?

Still, hope that it helps

Comments