Git Product home page Git Product logo

whatsapp-bot-seed's Introduction

whatsapp-bot-seed

A small python seed to create a Whatsapp Bot, with regex-callback routes (just like a web framework).
(practical extension of the examples on https://github.com/tgalal/yowsup)

⚠️ Warning ⚠️

Unfortunately, after some updates in the whatsapp servers, bots are beeing banned real quickly. Some just last a couple hours.
Whatsapp does not have an open protocol, so yowsup -- the core implementation behind this seed -- relies on reverse engineering to understand the messages exchange. Right now there is a lot of issues with this implementation.
This project had a good run, was really useful and bots prior to the server update could run for months without any trouble. Right now is very unstable and unreliable due the ban problem.
If a new library/protocol update solves this issue, the work will return. Until then, sadly, the project will be on hold.

What it does?

  • Basic message handling:
    Example

  • Automatic media (images and videos) download, and url print screens
    Example

  • Youtube Video Downloads, and Text to Speech
    Example

  • Google image and web search
    Example

  • Group administration
    Example
    and a bit more...

Installation

  1. Install the image handling system dependencies on bash opt/system-requirements.sh
  2. Create a virtualenv and install the requirements pip install -r opt/requirements.pip
  3. Follow the instructions on src/config.py to get the whatsapp credentials.
  4. Then just run the server with python src/server.py

Or with Docker!

$ git clone https://github.com/joaoricardo000/whatsapp-bot-seed/
$ cd whatsapp-bot-seed
(Edit Dockerfile to include your credentials)
$ docker build -t whatsapp-bot .
$ docker run -p 0.0.0.0:9005:9005 whatsapp-bot

The server will be running. Access http://localhost:9005 (default: admin:password) for process controll and logs.

To create your own views, check out src/router.py and src/view/basic_views.py for examples.

whatsapp-bot-seed's People

Contributors

joaoricardo000 avatar joyarzun avatar mrmstn avatar mukeshinnoventes avatar sanketdg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whatsapp-bot-seed's Issues

How to add a trigger to an external event and send a msg

Hi there.
I want to add an external event and this trigger a message by WA. The external event is other python process that has motion detection. So, when it detects motion this should trigger a msg to whatsapp-bot. In your project, the event is a message received that trigger a response. In a wider context, I have a raspberry pi with a cam. I want that RPI send me a message if the cam detect motion. How I can accomplish this? Any advice or help are grateful

Always "no valid session bad mac"

Hi,

today i always get no valid session bad mac repeatedly in shell when i start the bot.
I cannot send any messages anymore.

I already deleted axolotl db and restarted, same issue.
I updates yowsup2 again deleted axolotl db and restarted, same issue.

What can i do?
Anyone else with persistent "no valid session bad mac"

Help please.

Regards X23

cannot write/read files in mediadirectory

Traceback (most recent call last):
File "/home/pi/whatsapp-bot-seed/src/router.py", line 68, in handle_callback
data = callback(message, match)
File "/home/pi/whatsapp-bot-seed/src/views/google.py", line 38, in google_search
self.url_print_sender.send_by_url(jid=message.getFrom(), file_url=page_url)
File "/home/pi/whatsapp-bot-seed/src/utils/media_sender.py", line 56, in send_by_url
self._on_error(jid)
File "/home/pi/whatsapp-bot-seed/src/utils/media_sender.py", line 118, in _on_error
self.interface_layer.toLower(TextMessageProtocolEntity("{!}", to=jid))
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/init.py", line 63, in toLower
self.lower.send(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/__init
.py", line 173, in send
s.send(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/init.py", line 111, in send
send(entity)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/protocol_messages/layer.py", line 15, in sendMessageEntity
self.entityToLower(entity)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/init.py", line 115, in entityToLower
self.toLower(entity.toProtocolTreeNode())
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/init.py", line 63, in toLower
self.__lower.send(data)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/axolotl/layer.py", line 107, in send
self.handlePlaintextNode(node)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/axolotl/layer.py", line 169, in handlePlaintextNode
if not self.store.containsSession(recipient_id, 1):
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/axolotl/store/sqlite/liteaxolotlstore.py", line 56, in containsSession
return self.sessionStore.containsSession(recepientId, deviceId)
File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/axolotl/store/sqlite/litesessionstore.py", line 44, in containsSession
c.execute(q, (recipientId, deviceId))
InterfaceError: Error binding parameter 0 - probably unsupported type.
layer.py [ERROR][2015-10-23 12:40:10,314] No valid sessionsBad Mac!
layer.py [ERROR][2015-10-23 12:40:10,438] No valid sessionsBad Mac!

wildcard commands - mentioned

Hi all,

is there a way to wildcard a string? so if there is some name like "karsten" in the message, that it will react. something with ? or *

("^karsten*", self.hs)

thanks

How to set status and profile picture

Hello. this is a great bot. and I want to ask how to set status like "/help for information" also set a profile picture for the bot on config.py maybe??
Thank You

Whatsapp bot Not responding after a while

Hi There!

im running,testing, developing your great whatsapp-bot-seed framework, but iam running into an issue I noticed when the bot is running for a while it is not responding anymore in the whatsapp group.

After restarting the server.py it starts working again, it looks like that when the bot is idle for some time it stops responsing, any idea how to fix this?

Can someone help me to sort this variable in my python code?

Hi,

i changed the bot a lot for making a soccer management group (dates for playing and so on) i have a list that could be send by the bot when sending /liste and i need to sort it but i couldn't get to manage this i will always get errors:

here ist the code: http://pastebin.com/ue92R7K7

i need to sort the variable data before i return it, i tried .split() .splitlines() list(data) data.sort() and some other scary things but it will not work. Can anyone help please?

Variable data contains a string but when send it, it has line breaks that i don't enter myself this comes from reading the file content (look to the code), i am really bad in python and i think i need help.

Regards X23

Untrusted identity

Hello,

Since today I receive the message "Untrusted ID! !"
And the Bot starts ignoring the chat.

Is there any way to fix the issue?

Feature Request: Simple poll

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.

Where do I turn on and off the encryption?

First of all thanks a lot for this framework. It is quite easy to understand.

However there is a bug I face when I am in a group with another bot(not mine). I try to invoke an event but this error comes up:

`Traceback (most recent call last):
File "src\server.py", line 38, in start
self.stack.loop(timeout=0.5, discrete=0.5)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\stacks\yowstack.py", line 187, in loop
asyncore.loop(args, *kwargs)
File "c:\python35\Lib\asyncore.py", line 203, in loop
poll_fun(timeout, map)
File "c:\python35\Lib\asyncore.py", line 150, in poll
read(obj)
File "c:\python35\Lib\asyncore.py", line 87, in read
obj.handle_error()
File "c:\python35\Lib\asyncore.py", line 83, in read
obj.handle_read_event()
File "c:\python35\Lib\asyncore.py", line 423, in handle_read_event
self.handle_read()
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers\network\layer.py", line 86, in handle_read
self.receive(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers\network\layer.py", line 94, in receive
self.toUpper(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers__init
.py", line 59, in toUpper
self.upper.receive(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers\stanzaregulator\layer.py", line 28, in receive
self.processReceived()
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers\stanzaregulator\layer.py", line 48, in processReceived
self.toUpper(oneMessageData)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers__init
.py", line 59, in toUpper
self.upper.receive(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers\auth\layer_crypt.py", line 63, in receive
self.toUpper(payload)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers__init
.py", line 59, in toUpper
self.upper.receive(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers\coder\layer.py", line 35, in receive
self.toUpper(node)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers__init
.py", line 59, in toUpper
self.upper.receive(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers\logger\layer.py", line 14, in receive
self.toUpper(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers__init
.py", line 59, in toUpper
self.upper.receive(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers\axolotl\layer.py", line 126, in receive
self.toUpper(protocolTreeNode)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers__init
.py", line 59, in toUpper
self.upper.receive(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers__init
.py", line 169, in receive
s.receive(data)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers__init__.py", line 105, in receive
recv(node)
File "X:\Coding\PYTHON\whatapp\lib\site-packages\yowsup\layers\auth\layer_authentication.py", line 89, in handleStreamError
raise AuthError("Unhandled stream:error node:\n%s" % node)
yowsup.layers.auth.autherror.AuthError: Unhandled stream:error node:
stream:error


/stream:error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "src\server.py", line 53, in
server.start()
File "src\server.py", line 40, in start
logging.exception("Authentication Error: %s" % e.message)
AttributeError: 'AuthError' object has no attribute 'message'
`

If this is indeed the problem of encryption, then where can it be switched on and off?
Any help is appreciated.

Can we implement a translation option?

Hi,

can we use google speech api to translate text into another language?
Lets say we define a default language (as input text) for example DE (German)

Then we use the switch "/l" (l like "l"anguage) followed by the destination language "EN" plus the text we need translate "Hallo Welt"

/l EN Hallo Welt

Output should be "Hallo Welt" in english "Hello World"

Regards X23

auth error trying to connect

Hi,

I've registered a new phone number using yowsup, but when I launch the server with the received credentials I get an Auth Error message:

_yowstack.py_   [DEBUG][2015-12-06 19:32:49,688] Initializing stack
_yowstack.py_   [DEBUG][2015-12-06 19:32:49,688] Constructed Network Layer
_yowstack.py_   [DEBUG][2015-12-06 19:32:49,688] Constructed Stanza Regulator Layer
_yowstack.py_   [DEBUG][2015-12-06 19:32:49,688] Constructed Crypt Layer
_yowstack.py_   [DEBUG][2015-12-06 19:32:49,688] Constructed Coder Layer
_yowstack.py_   [DEBUG][2015-12-06 19:32:49,688] Constructed Logger Layer
_yowstack.py_   [DEBUG][2015-12-06 19:32:49,688] Constructed Axolotl Layer
_yowstack.py_   [DEBUG][2015-12-06 19:32:49,688] Constructed Authentication Layer - Messages Layer - Receipt Layer - Ack Layer - Presence Layer - Ib Layer - Iq Layer - notification Ib Layer - Iq Layer - Chatstate Layer - call Layer - Groups Iq Layer - Media Layer - Privacy Layer - Profiles Layer
_yowstack.py_   [DEBUG][2015-12-06 19:32:49,689] Constructed Interface Layer - Interface Layer
_layer.py_  [DEBUG][2015-12-06 19:32:49,689] Connecting to e8.whatsapp.net:443
_server.py_ [INFO][2015-12-06 19:32:49,801] ##################################################
_server.py_ [INFO][2015-12-06 19:32:49,801]     Server started. Phone number: xxxxxxxxxxx
_server.py_ [INFO][2015-12-06 19:32:49,802] ##################################################
_layer.py_  [DEBUG][2015-12-06 19:32:50,061] tx:
<stream:features>
<readreceipts>
</readreceipts>
<groups_v2>
</groups_v2>
<privacy>
</privacy>
<presence>
</presence>
</stream:features>

_layer.py_  [DEBUG][2015-12-06 19:32:50,066] tx:
<auth passive="false" user="34686617206" mechanism="WAUTH-2">
(code snipped)
</auth>

_layer.py_  [DEBUG][2015-12-06 19:32:50,454] rx:
<stream:features>
</stream:features>

_layer.py_  [DEBUG][2015-12-06 19:32:50,454] rx:
<challenge>
(code snipped)
</challenge>

_layer.py_  [DEBUG][2015-12-06 19:32:50,460] tx:
<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
(code snipped)
</response>

_layer.py_  [DEBUG][2015-12-06 19:32:52,675] rx:
<failure>
<not-authorized>
</not-authorized>
</failure>

_layer.py_  [DEBUG][2015-12-06 19:32:52,675] Disconnected, reason: Authentication Failure
_server.py_ [ERROR][2015-12-06 19:32:52,675] Authentication Error: not-authorized

The yowsup-cli script works fine, I can send messages with the same credentials, do you know what can be wrong?

Thank you in advance.

download images or videos and send them as media

hi guys,

i got an image board api which im selecting random images or videos.
so i can go like /random funnystuff

i coded everything that i get a random url back of the image or a video.
now i want to download this url image and send it to the chat.

can someone tell me how?
same with video. its an else if statement.

thx

Error: old_version

How do I resolve the error below?

INFO:yowsup.common.http.warequest:{"status":"fail","reason":"old_version"}

status: fail
reason: old_version

Thank you, wait.

can i use the bot and yowsup-cli together at the same time/number?

Hi,

i need to trigger external message event for this i wanna use yowsup-cli but i am not clear with the bot and yowsup-cli itself.

Can i use the bot and yowsup together at the same time with the same account?
If yes is it only one time needed to register and after this i just can use the credentials?

Is the bot using yowsup with its own credentials file or will it store credentials to yowsup?

Regards X23

Joao Preciso muito de sua ajuda '-' pls

tudo deu certo aqui , ja cadastrei o numero e tudo , mas quando vou executar o servidor da esse erro :

(process:17039): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
dosnut@dosnut-X451CA:~/whatsbot/whatsapp-bot-seed-master/src$ python server.py
Traceback (most recent call last):
File "server.py", line 50, in
server = YowsupEchoStack(config.auth)
File "server.py", line 29, in init
self.stack.setCredentials(credentials)
File "build/bdist.linux-x86_64/egg/yowsup/stacks/yowstack.py", line 155, in setCredentials
File "build/bdist.linux-x86_64/egg/yowsup/layers/auth/layer_authentication.py", line 42, in setCredentials
File "build/bdist.linux-x86_64/egg/yowsup/layers/auth/layer_authentication.py", line 37, in __getCredentials
File "/usr/lib/python2.7/base64.py", line 76, in b64decode
raise TypeError(msg)
TypeError: Incorrect padding

por favor se puder ajudar , agradeço :D

Not able to download Youtube Videos

When a youtube url is passed the following error is raised

CipherError: Couldn't cipher the signature. Maybe YouTube has changed the cipher algorithm. Notify this issue on GitHub: Could not find JS function '
rr'

Error on exec: No such signedprekeyrecord! 48324

When I start the server, I get the next error:
_layer.py_ [ERROR][2015-12-23 23:45:55,057] No such signedprekeyrecord! 48324
Yesterday, the bot works.
I tried re-register and change src/config.py parameters about user & password/token (updating yowsup2, previously), but still without work.

Bot not working

I have installed all requirements and has started the server.
A continous loop was running with server restarting again and again. It continued for some time and then it stop (see picture given below)
http://i.imgur.com/Mz3Ybo1.png

I tried to message to that number from whatsapp but there was no reply. it is not even showing as online. Messages are also not delivered. I am running this on my Ubuntu 14.04 VPS.

How to trigger a message based on an external event like time/date?

Hi there, first of all thanks a lot for this little framework! It's really helpful to abstract away all the complexity from yowsup. I've forked your repo and have been customizing the hell out of it for my own needs. You might be interested in some features for which I can make a PR, just check out what I have here in my repo (things like movie search using themoviedb.org or weather using openweathermap).

Anyway, I was thinking about another feature that would be nice. I'd like to make the bot send happy birthday automatically to a group by comparing the current date with a pre-defined set of dates.

However I figured that to achieve this I'd have to somehow hook into the main yowsup loop and then check if today's date matches any of the birthdays, every 24h or so. But I have no idea how to do this at the moment so I wonder if you have any.

Thanks!

Action every 5 mins

Hi, i'm new here with all this python and your great bot.

But I want to send message every 5 mins to my group.

Where can i paste the code to execute it every 5 mins?

Thanks!

Error, help please

When I use the command "sudo yowsup-cli demos -l (Number):(Pwd)= -y" I get this error in the terminal " ERROR:yowsup.layers.axolot1.layer : No valid sessionsBad Mac! " I dont know why it happened, before that it used to work properly.

Where to locate the log file?

Hi,

where can i find the log the bot is writing?

# Logging configuration.
# By default only logs the command messages.
# If logging_level set to logging.DEBUG, yowsup will log every protocoll message exchange with server.
import logging

log_format = '_%(filename)s_\t[%(levelname)s][%(asctime)-15s] %(message)s'
logging_level = logging.INFO

Well i can start the bot while adding
> /tmp/bot.log

but any hints with python log usage will be nice.

Regards X23

Filter groups and admins how does it work?

Hi,

in config there is this option:

filter_groups = False
admins = ["XXXXXXXXXXXX", ]

If filter_groups is True, the bot only stays
at groups that there is at least one admin on it.
Otherwise will leave instantly if added.

When True the bot will leave any group where the last admin has left?
What about admins = ? is the bot unable to detect natively who is a group admin?
Should i enter my WA "display name"?
What if it contains spaces?
And can i enter multiple admins like ["the admin1", "the admin2"]?

Regards X23

Script stops working if I lose internet connectivity while the script is running

Hi.

First of all, thanks for making the library. I would never have figured out how to use yowsup on my own.

I am running the script on a raspberry pi in headless mode. Internet connectivity is not that great here and when I lose my connection the script just stops working. Like, no error message, no exceptions, nothing.

Shouldn't this bit 'self.stack.loop(timeout=0.5, discrete=0.5)' produce an error/exception when the internet is down? I tried to add try/except around server.start() and wanted to exit the script, so that supervisor can restart the script. But the code never stops running.

Can't figure out why. Any help on the matter will be appreciated.

Thanks again!

Get contacts profile picture to send it with an answer?

Hi,

is there a way to to recieve a contacts profile picture, save it to a filesystem path (as number(at)s.whatsapp.net.jpg/png), and then send an answer (picture) with contacts profile picture recently recieved?

Regards X23

Untrusted identity

I get this today when i test the new ver.

[ERROR][2015-10-29 21:00:17,565] Untrusted identity!!
[WARNING][2015-10-29 21:00:17,565] Ignoring message with untrusted identity

Yesterday its works fine but now i got this

...stuck??

INFO:root:Starting....
INFO:yowsup.layers.axolotl.layer:Axolotl layer is generating keys
INFO:root:Starting....

Doesnt move from there.

/i iPhone doesn't work

When I try to use /i iPhone, this happens:

server.py [ERROR][2015-11-08 11:55:13,712] Unexpected Exception:
Traceback (most recent call last):
File "smartbot/src/server.py", line 38, in start
self.stack.loop(timeout=0.5, discrete=0.5)
File "/usr/lib/python2.7/site-packages/yowsup/stacks/yowstack.py", line 187, in loop
asyncore.loop(_args, *_kwargs)
File "/usr/lib64/python2.7/asyncore.py", line 216, in loop
poll_fun(timeout, map)
File "/usr/lib64/python2.7/asyncore.py", line 145, in poll
r, w, e = select.select(r, w, e, timeout)
error: (9, 'Bad file descriptor')
server.py [INFO][2015-11-08 11:55:13,712] Restarting..

server.py [INFO][2015-11-08 11:55:13,711] Server started. Phone number: 1631XXXXXXX
server.py [INFO][2015-11-08 11:55:13,711] ##################################################

Permission problems/errors with /s /t /i weburl while pictureurl and youtube works

Hi,

i have the same issue and i don't think that this is a filesystem problem its seems that it's another pakage used that will not work as root: http://pastebin.com/9WNJP9pU

You are not allowed to run this app with root permissions.
If running without sudo doesn't work, you can either fix your permission problems or change where npm stores global packages by putting ~/npm/bin in your PATH and running:
npm config set prefix ~/npm

I've done what the error message told me also i uninstalled all npm modules and reinstalled them via nvm without needed root but anyway the error persists.

The above happens while using /s

When using /t the bot answers only {!} but an mp3 file is been created under /tmp:
http://i.imgur.com/9F0242q.png

When using /i i get the error: TypeError: 'NoneType' object has no attribute 'getitem'
http://pastebin.com/kFVuaKkv

When sending web url like http://google.de it same error like with /s and permission problem with the /tmp path

What works is http links to pictures and youtube videos.

Any ideas which modules are the problem here and howto fix this issues?

Regards X23

trying to trim strings after command

my python is not well enough to get this done, so maybe someone can help me here.
i want to add a command like "/user 'name here'" and get the stuff between ' ' in a variable.

that i can use it for other things.
i dont know where to add this, the commands are defined in the "super_views.py" thats fine, but the bot will fetch messages and waits for a trigger, so i need to add it there in someway,

anybody an idea?

thx

Added teamspeak start script for whatsapp seed bot.

Dont know if anybody needs that and it seems to be the wrong place for posting this but.

from utils.media_sender import UrlPrintSender
from yowsup.layers.protocol_messages.protocolentities.message_text import TextMessageProtocolEntity
import random
import subprocess
import os

class SuperViews():
    def __init__(self, interface_layer):
        self.interface_layer = interface_layer
        self.url_print_sender = UrlPrintSender(self.interface_layer)
        self.routes = [
            ("^/help", self.help),
            ("^/teamspeak status", self.status),
            ("^/about", self.about),
            ("^/teamspeak start",self.sup),
            ("^/roll", self.roll),
            ("/(?P<evenOrOdd>even|odd)$", self.even_or_odd),
        ]
def about(self, message=None, match=None, to=None):
    self.url_print_sender.send_by_url(message.getFrom(), "https://github.com/joaoricardo000/whatsapp-bot-seed", ABOUT_TEXT)

def roll(self, message=None, match=None, to=None):
    return TextMessageProtocolEntity("[%d]" % random.randint(1, 6), to=message.getFrom())

def even_or_odd(self, message=None, match=None, to=None):
    is_odd = len(match.group("evenOrOdd")) % 2
    num = random.randint(1, 10)
    if (is_odd and num % 2) or (not is_odd and not num % 2):
        return TextMessageProtocolEntity("[%d]\nYou win." % num, to=message.getFrom())
    else:
        return TextMessageProtocolEntity("[%d]\nYou lose!" % num, to=message.getFrom())

def help(self, message=None, match=None, to=None):
    return TextMessageProtocolEntity(HELP_TEXT, to=message.getFrom())

def status(self, message=None, match=None, to=None):
    proc = subprocess.Popen('/home/ts3/ts3server_startscript.sh status', shell=True, stdout=subprocess.PIPE)
    tmp = proc.stdout.read()
    return TextMessageProtocolEntity(tmp, to=message.getFrom());

def sup(self, message=None, match=None, to=None):
     proc = subprocess.Popen('/home/ts3/ts3server_startscript.sh start', shell=True, stdout=subprocess.PIPE)
     tmp = proc.stdout.read()
     return TextMessageProtocolEntity(tmp, to=message.getFrom());`

AuthError: not-authorized

Hi, When I use yowsup-cli directly in console, it works fine, after I add the credentials to the config file, I am getting this error.

File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/auth/layer_authentication.py", line 77, in handleFailure

raise AuthError(nodeEntity.getReason())

AuthError: not-authorized

Any idea?

Whatsapp bans number when using the Group Admin views

Right now, the group admin views does not check if the bot is in fact a group admin, and if the commands are valid. For example, when someone sends a /kick with an invalid number, or even if the number is not on the group.
This causes the bot to send wrong messages (messages that would not be possible using the official app) and usually bans the number of the server after a couple errors.

This can be solved checking the validity of the request before sending. It is a functionality to be soon added, until then GroupAdminViews will be disabled by default.

Python 3.4: only a few commands working :/

if i post an image or want to search something the console just shows me:

_media_sender.py_ [ERROR][2016-01-28 12:23:36,728] Unicode-objects must be encoded before hashing Traceback (most recent call last): File "/home/scripts/wabot/test/whatsapp-bot-seed/src/utils/media_sender.py", line 191, in send file_path = self.tts_record(text, lang) File "/home/scripts/wabot/test/whatsapp-bot-seed/src/utils/media_sender.py", line 198, in tts_record file_path = self._build_file_path(text) File "/home/scripts/wabot/test/whatsapp-bot-seed/src/utils/media_sender.py", line 204, in _build_file_path id = hashlib.md5(text).hexdigest() TypeError: Unicode-objects must be encoded before hashing

Group message send : AttributeError: 'NoneType' object has no attribute 'getChild'

When I try to send message to a groupe this error occurs and crashes the program :

  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/layer.py", line 121, in receive
    if not self.processIqRegistry(protocolTreeNode):
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/__init__.py", line 155, in processIqRegistry
    successClbk(protocolTreeNode, originalIq)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/layer.py", line 181, in <lambda>
    self._sendIq(entity, lambda a, b: self.onGetKeysResult(a, b, self.processPendingMessages), self.onGetKeysError)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/layer.py", line 345, in onGetKeysResult
    entity = ResultGetKeysIqProtocolEntity.fromProtocolTreeNode(resultNode)
  File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.4.48-py2.7.egg/yowsup/layers/axolotl/protocolentities/iq_keys_get_result.py", line 87, in fromProtocolTreeNode
    preKeyId = ResultGetKeysIqProtocolEntity._bytesToInt(preKeyNode.getChild("id").getData())
AttributeError: 'NoneType' object has no attribute 'getChild'

It just occured, I managed to send message to a group before I restarted the program...
Any idea of where this is coming from?

Error: Could not determine image dimensions

The bot has been troubling me for ages.

Do you know why this error pops up:

File "/usr/local/lib/python2.7/dist-packages/yowsup/layers/protocol_media/protocolentities/message_media_downloadable_image.py", line 89, in fromFilePath
assert dimensions, "Could not determine image dimensions"

AssertionError: Could not determine image dimensions

config.py, must pay to activate ?

Hello

I don't understand why there are mention of " price: US$0.99" in the config.py.

We must pay something to activate the bot ?

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.