如何制作子菜单?

时间:2017-10-30 20:39:57

标签: python yowsup

我想帮助制作子菜单,从菜单编号" 1"。我尝试使用下面的代码,但它没有用。

这是我的代码:

<?php
if(isset($_GET['domain'])) {
    $domain = trim($_GET['domain']);
    if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7);
    if(substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);
    if(ValidateIP($domain)) {
        echo "hello before check";
        $result = LookupIP($domain);
    }
    elseif(ValidateDomain($domain)) {
        $result = LookupDomain($domain);
    }
    else die("Invalid Input!");
    echo "<pre>\n" . $result . "\n</pre>\n";
}

以下是我想作为子菜单放置的@signals.message_received.connect def handle(message): # Main menu if message.command == "Olá": menuPrincipal(message) # 1 - Budgeting elif message.command == "1": orcamentos(message) # 2 - Track an order already in progress elif message.command == "2": pedidoAndamento(message) # 3 - Change the date, time or location of the event elif message.command == "3": alterarPedido(message) # 4 - Special Offers elif message.command == "4": promocoes(message) # 5 - Speak to a representative elif message.command == "5": chamarRepresentante(message) 函数:

orcamentos()

1 个答案:

答案 0 :(得分:0)

您可以使用正则表达式或&#39; 关键字,例如:if&#34; 1&#34;在message.command中: 但我更喜欢使用正则表达式,因此将更明确地指出用户类型是否是命令。

如果您想压缩文件(因为我在我的机器人中有30 +菜单),您可能希望将它们保存在单独的文件中,这样您就可以使用此界面文件&#39; yowsup .layers.interface &#39;其中包含&#39; YowInterfaceLayer,ProtocolEntityCallback &#39;。

&#34; ^有趣$&#34; 这个正则表达式会检测到有趣的单词和&#34; ^ wiki(?P [^ $] +)$&# 34; 将检测关键字wiki之后的单词,因此它可以更好地控制命令。